-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[bugfix] Resolve bug with multiple optimizers and toggle. #5574
Conversation
Hello @tchaton! Thanks for updating this PR.
Comment last updated at 2021-01-25 20:48:57 UTC |
@@ -1166,16 +1166,44 @@ def toggle_optimizer(self, optimizer: Optimizer, optimizer_idx: int): | |||
|
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.
maybe just use the opt_idx to get the optimizer down there... just to unify the arguments with untoggle_optimizer
. Either way is fine.
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.
Sounds great ! I will do so.
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.
Do you plan to do it in this PR?
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.
@tchaton ^^
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.
Codecov Report
@@ Coverage Diff @@
## master #5574 +/- ##
======================================
- Coverage 93% 93% -0%
======================================
Files 135 135
Lines 10034 10051 +17
======================================
+ Hits 9369 9383 +14
- Misses 665 668 +3 |
Co-authored-by: Rohit Gupta <[email protected]>
* fix toggle_optimizer * update doc * resolve bug * update * Update pytorch_lightning/core/lightning.py Co-authored-by: Rohit Gupta <[email protected]> * update on comments * update on comments * update Co-authored-by: Rohit Gupta <[email protected]> (cherry picked from commit c76cc23)
* fix toggle_optimizer * update doc * resolve bug * update * Update pytorch_lightning/core/lightning.py Co-authored-by: Rohit Gupta <[email protected]> * update on comments * update on comments * update Co-authored-by: Rohit Gupta <[email protected]> (cherry picked from commit c76cc23)
* fix toggle_optimizer * update doc * resolve bug * update * Update pytorch_lightning/core/lightning.py Co-authored-by: Rohit Gupta <[email protected]> * update on comments * update on comments * update Co-authored-by: Rohit Gupta <[email protected]> (cherry picked from commit c76cc23)
* fix toggle_optimizer * update doc * resolve bug * update * Update pytorch_lightning/core/lightning.py Co-authored-by: Rohit Gupta <[email protected]> * update on comments * update on comments * update Co-authored-by: Rohit Gupta <[email protected]> (cherry picked from commit c76cc23)
What does this PR do?
In case of multiple optimizers, toggle optimizer was called.
It would lose user requieres_grad state by setting everything to True or False.
This is erroneous in case there are any parameters which are explicitly kept non-trainable.
Fixes #5292 #5642
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃