-
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
Disable lr_scheduler.step()
in manual optimization
#6825
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6825 +/- ##
=======================================
- Coverage 92% 91% -1%
=======================================
Files 197 197
Lines 12588 12821 +233
=======================================
+ Hits 11610 11696 +86
- Misses 978 1125 +147 |
lr_scheduler.step()
in manual optimization [WIP]lr_scheduler.step()
in manual optimization
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
@@ -32,7 +32,7 @@ def update_learning_rates(self, interval: str, monitor_metrics=None): | |||
interval: either 'epoch' or 'step'. | |||
monitor_metrics: dict of possible values to monitor | |||
""" | |||
if not self.trainer.lr_schedulers: | |||
if not self.trainer.lr_schedulers or not self.trainer.train_loop.automatic_optimization: |
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.
Let's update the doc with this change + add a warning if we detect the scheduler was on step or epoch, but never triggered.
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 I updated the docs and added a warning when scheduler keys (e.g. "interval", "frequency", "monitor"), which are invalid in manual optimization, are provided. Would you mind having a look at the changes?
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.
Looks good. Could we add in the doc how to use the scheduler for interval=epoch
.
def training_step(self, batch, batch_idx)
# do optimization
if self.trainer.is_last_batch: # is_last_batch doesn't exist for the trainer, could be added.
self.lr_schedulers[0].step()
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 I added self.trainer.is_last_batch
and updated the docs. Could you have a look again?
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.
Great work there !
@akihironitta. There is a bug with Pipe. Better to access |
I think the failing tests on Windows are not related to the changes here as they're also failing on master.
|
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.
seems like all Windows tests are failing
Windows errors are caused by #6762 |
Just for the note, as #6907 has been merged already, there's no need to change any docs here, so I reverted the docs change. |
What does this PR do?
Fixes #6379. Once #6567 and this PR are merged, users can call
lr_scheduler.step()
at arbitrary intervals in manual optimization for ultimate flexibility.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 🙃