Lightning-AI / Lightning-AI/pytorch-lightning
Add "interval": "validation" to scheduler configuration
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
## 🚀 Feature
This request concerns the optimizer Scheduler.
For now, the scheduler can be configured like this:
```python
lr_scheduler_config = {
"scheduler": lr_scheduler,
"interval": "epoch", # epoch, step
"frequency": 1,
"monitor": "val_loss",
"strict": True,
"name": None,
}
```
It would be great to add the option `"interval": "validation"`.
### Motivation
My use case is the following. I want to `.step()` the scheduler after each evaluation step, using an evaluation metric and `ReduceLROnPlateau` scheduler.
Sometimes **(1)** I'm using a bigger dataset, so in the case I use `val_check_interval=0.1`.
and Other times **(2)** I'm using smaller dataset, so I use `check_val_every_n_epoch=5`.
The current interval options are not working for me. `step` will call the scheduler each step, and `epoch` will do it after each epoch, however, for my case **(1)**, the scheduler will be called once every 10 validations, and in **(2)**, the scheduler will be called before the validation, and I will get the error `pytorch_lightning.utilities.exceptions.MisconfigurationException: ReduceLROnPlateau conditioned on metric my_quantity which is not available. Available metrics are: ['train/loss']. Condition can be set using 'monitor' key in lr scheduler dict`.
I hope this is clear for you.
cc @borda @tchaton @rohitgr7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start at the optimizer Scheduler configuration and trace how interval, val_check_interval, and check_val_every_n_epoch control stepping, especially for ReduceLROnPlateau. Done means a validation interval triggers stepping for both example setups and the monitored metric is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100