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

[PyTorch] Use same API in optimizer zero_grad as PyTorch optimizers #1466

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timmoon10
Copy link
Collaborator

Description

The fused optimizers (copied from Apex in #867) have a non-standard API that makes it annoying to swap with the vanilla PyTorch optimizers. This PR deprecates the set_grad_none kwarg in FusedAdam and FusedSGD in favor of a set_to_none kwarg in zero_grad, similar to the vanilla PyTorch API. I've also modified some of the constructor kwargs to be more consistent with PyTorch.

Closes #1453.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

  • Deprecate set_grad_none kwarg in FusedAdam and FusedSGD in favor of set_to_none kwarg in zero_grad
  • Reorder kwargs in FusedAdam and FusedSGD constructors

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@timmoon10 timmoon10 added the enhancement New feature or request label Feb 8, 2025
@timmoon10
Copy link
Collaborator Author

/te-ci pytorch

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

Successfully merging this pull request may close these issues.

FusedAdam optimizer doesn't have set_to_none keyword argument
1 participant