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>
| 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.
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.
@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.
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.
@tchaton I added self.trainer.is_last_batch and updated the docs. Could you have a look again?
|
@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. |
Borda
left a comment
There was a problem hiding this comment.
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 🙃