Skip to content

Clip norm after scaler.unscale_ in native fp16 training #9599

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

Closed
del2z opened this issue Sep 19, 2021 · 2 comments · Fixed by #9606 or #9287
Closed

Clip norm after scaler.unscale_ in native fp16 training #9599

del2z opened this issue Sep 19, 2021 · 2 comments · Fixed by #9606 or #9287
Assignees
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task
Milestone

Comments

@del2z
Copy link

del2z commented Sep 19, 2021

🐛 Bug

I trained a large model using native amp, but the loss converged very slow. After a careful check of the backward and optimization code, I found the clip_gradients is executed right after backward, but scaler.unscale_ is conducted in pre_optimization_step.
According to the instruction of Pytorch, the order of clip and unscale should be exchanged. Currently gradient_clip_val may lead to a very flat learning curve if used together with native amp.
Hope to be fixed.

@del2z del2z added bug Something isn't working help wanted Open to be worked on labels Sep 19, 2021
@justusschock justusschock self-assigned this Sep 20, 2021
@justusschock
Copy link
Member

Hey @del2z ,

thanks for letting us know. I just checked and it seems you are right. I'll get to work on this ASAP :)

@cowwoc
Copy link
Contributor

cowwoc commented Oct 3, 2021

I believe this is fixed in release 1.4.9: https://github.com/PyTorchLightning/pytorch-lightning/releases/tag/1.4.9

Can this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task
Projects
None yet
3 participants