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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make optimizers skippable when using amp #7975

Merged
merged 4 commits into from Jun 16, 2021

Conversation

yifuwang
Copy link
Contributor

@yifuwang yifuwang commented Jun 14, 2021

What does this PR do?

Fixes #4524 and #7792. Currently users run into the following error when skipping an optimizer with amp enabled:

assert len(optimizer_state["found_inf_per_device"]) > 0, "No inf checks were recorded for this optimizer."

This is because GradScaler isn't happy with stepping an optimizer when none of the parameters it tracks has gradient.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 馃檭

@codecov
Copy link

codecov bot commented Jun 14, 2021

Codecov Report

Merging #7975 (b4ef91e) into master (78a14a3) will decrease coverage by 5%.
The diff coverage is 0%.

@@           Coverage Diff           @@
##           master   #7975    +/-   ##
=======================================
- Coverage      92%     87%    -5%     
=======================================
  Files         207     207            
  Lines       13368   13370     +2     
=======================================
- Hits        12238   11602   -636     
- Misses       1130    1768   +638     

Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

LGTM

tests/plugins/test_amp_plugins.py Outdated Show resolved Hide resolved
tests/plugins/test_amp_plugins.py Outdated Show resolved Hide resolved
@awaelchli awaelchli added the bug Something isn't working label Jun 15, 2021
@awaelchli awaelchli added this to the v1.3.x milestone Jun 15, 2021
@awaelchli awaelchli added the ready PRs ready to be merged label Jun 15, 2021
@Borda Borda enabled auto-merge (squash) June 15, 2021 21:31
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

@yifuwang pls add changelog entry

@Borda Borda disabled auto-merge June 15, 2021 21:31
@yifuwang
Copy link
Contributor Author

@Borda thanks for the reminder! Updated.

@carmocca carmocca enabled auto-merge (squash) June 15, 2021 23:58
@carmocca carmocca merged commit b71aa55 into Lightning-AI:master Jun 16, 2021
@carmocca
Copy link
Contributor

awaelchli pushed a commit that referenced this pull request Jun 21, 2021
Co-authored-by: Yifu Wang <yifuwang@2012@gmail.com>
Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
lexierule pushed a commit that referenced this pull request Jun 22, 2021
Co-authored-by: Yifu Wang <yifuwang@2012@gmail.com>
Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when disabling an optimizer with native AMP turned on
5 participants