-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix zero-grad behavior when entering the validation loop #18710
Conversation
Trainer.validate/test/predict
Trainer.validate/test/predict
⚡ Required checks status: All passing 🟢Groups summary🟢 pytorch_lightning: Tests workflowThese checks are required after the changes to 🟢 pytorch_lightning: Azure GPU
These checks are required after the changes to 🟢 pytorch_lightning: Benchmarks
These checks are required after the changes to 🟢 pytorch_lightning: Docs
These checks are required after the changes to 🟢 mypy
These checks are required after the changes to 🟢 installThese checks are required after the changes to Thank you for your contribution! 💜
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #18710 +/- ##
==========================================
- Coverage 84% 49% -35%
==========================================
Files 439 431 -8
Lines 34363 34222 -141
==========================================
- Hits 28795 16819 -11976
- Misses 5568 17403 +11835 |
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.
just minor formating, feel free to ignore
Co-authored-by: Jirka Borovec <[email protected]>
Co-authored-by: Jirka Borovec <[email protected]>
for more information, see https://pre-commit.ci
What does this PR do?
Fixes #18713
This PR does the following:
zero_grad()
call is now wrapped by a new hookLightningModule.on_validation_model_zero_grad()
that the user can override if they don't want the default behavior (Should the model's grads be cleared before entering the validation loop? #18713).trainer.validate/test/predict
as a precaution (no change there).📚 Documentation preview 📚: https://pytorch-lightning--18710.org.readthedocs.build/en/18710/
cc @carmocca @awaelchli @Borda @justusschock