Skip to content
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

Add set_to_none to AcceleratedOptimizer.zero_grad #43

Merged
merged 1 commit into from
Apr 23, 2021
Merged

Add set_to_none to AcceleratedOptimizer.zero_grad #43

merged 1 commit into from
Apr 23, 2021

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Apr 23, 2021

This PR adds support for the keyword argument set_to_none in AcceleratedOptimizer.zero_grad, with a version check as PyTorch only introduced it in v1.7.0.

Fixes #42

@sgugger sgugger merged commit e0a420f into main Apr 23, 2021
@sgugger sgugger deleted the fix_42 branch April 23, 2021 18:22
)
self.optimizer.zero_grad()
else:
if set_to_none is not None:

Choose a reason for hiding this comment

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

if set_to_none is None:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!

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

Successfully merging this pull request may close these issues.

AcceleratedOptimizer zero_grad argument not supported: set_to_none
2 participants