Skip to content

Fix 2.8 issue per sample grad #3460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: RC-TEST-2.8
Choose a base branch
from
Draft

Fix 2.8 issue per sample grad #3460

wants to merge 7 commits into from

Conversation

svekars
Copy link
Contributor

@svekars svekars commented Jul 14, 2025

Copy link

pytorch-bot bot commented Jul 14, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3460

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures

As of commit d67bcb8 with merge base 9a44439 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the cla signed label Jul 14, 2025
@svekars svekars changed the base branch from main to RC-TEST-2.8 July 14, 2025 21:09
@svekars svekars added the 2.8 label Jul 14, 2025
@svekars svekars requested a review from albanD July 17, 2025 17:50
@svekars
Copy link
Contributor Author

svekars commented Jul 17, 2025

@albanD can you take a look?

Copy link
Contributor

@mikaylagawarecki mikaylagawarecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite confused by this change, as well as why this fails with the 2.8 RC :/ is the issue that we need to increase the tolerance?

print(f"Parameter {name}: max difference = {max_diff}")

# Optional: still assert for very large differences that might indicate real problems
assert max_diff < 0.5, f"Extremely large difference in {name}: {max_diff}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we change this to not use allclose anymore?


# Print differences instead of asserting
max_diff = (per_sample_grad - ft_per_sample_grad).abs().max().item()
print(f"Parameter {name}: max difference = {max_diff}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we printing this? On a side note, could you share what this prints with the 2.8 RC?

Comment on lines +175 to +180
idx = list(model.named_parameters()).index((name, model.get_parameter(name)))
per_sample_grad = per_sample_grads[idx]

# Check if shapes match and reshape if needed
if per_sample_grad.shape != ft_per_sample_grad.shape and per_sample_grad.numel() == ft_per_sample_grad.numel():
ft_per_sample_grad = ft_per_sample_grad.view(per_sample_grad.shape)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by this part

Is the issue that torch.allclose now fails due to the ordering of per_sample_grad and ft_per_sample_grad being different during zip?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants