-
Notifications
You must be signed in to change notification settings - Fork 31
Create rule S6981: Gradients should be scaled when using mixed precision #3966
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
base: master
Are you sure you want to change the base?
Conversation
90dd671
to
4cfbb88
Compare
4cfbb88
to
0660c9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a small change to make the CI pass. And a suggestion for the example. Nothing major.
rules/S6981/python/rule.adoc
Outdated
|
||
If the gradients underflow, the model might not learn properly and the training might be unstable. | ||
|
||
== How to fix it in Pytorch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be PyTorch, this is in the list of potential frameworks. But I think as long as we don't have the rule specified for multiple frameworks we should just leave it with a simple How to fix it
rules/S6981/python/rule.adoc
Outdated
with torch.autocast(device_type="cuda"): | ||
output = model(x) | ||
loss = torch.nn.functional.cross_entropy(output, y) | ||
loss.backward() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here maybe we could just add the Noncompliant comment
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Don't forget to add a title to the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An implementation challenge, but possibly a good example of an issue to write a blog post about?
1b9243b
to
36a7291
Compare
|
You can preview this rule here (updated a few minutes after each push).
Review
A dedicated reviewer checked the rule description successfully for: