You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that if I want to specify a return type I have to choose OptimizerLRSchedulerConfig (or OptimizerLRScheduler) since that is the only sub type of OptimizerLRScheduler (the return type of configure_optimizers) that is a dict.
When I run that I get
lightning_fabric.utilities.exceptions.MisconfigurationException: `configure_optimizers` must include a monitor when a `ReduceLROnPlateau` scheduler is used. For example: {"optimizer": optimizer, "lr_scheduler": scheduler, "monitor": "metric_to_track"}
But I cannot add 'monitor': 'metric_to_track' to my returned dict since then mypy complains
error: Extra key "monitor" for TypedDict "OptimizerLRSchedulerConfig" [typeddict-unknown-key]
Suggested fix
I suggest to replace
class OptimizerLRSchedulerConfig(TypedDict):
optimizer: Optimizer
lr_scheduler: NotRequired[Union[LRSchedulerTypeUnion, LRSchedulerConfigType]]
from utilities/types.py with
class OptimizerConfigDict(TypedDict):
optimizer: Optimizer
class OptimizerLRSchedulerConfigDict(TypedDict):
optimizer: Optimizer
lr_scheduler: Union[LRSchedulerTypeUnion, LRSchedulerConfigType]
monitor: str
#- PyTorch Lightning Version (e.g., 2.4.0):
#- PyTorch Version (e.g., 2.4):
#- Python version (e.g., 3.12):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
More info
No response
The text was updated successfully, but these errors were encountered:
Bug description
As suggested in the docs my configure_optimizers looks ruffly like this:
Note that if I want to specify a return type I have to choose
OptimizerLRSchedulerConfig
(orOptimizerLRScheduler
) since that is the only sub type ofOptimizerLRScheduler
(the return type ofconfigure_optimizers
) that is a dict.When I run that I get
But I cannot add
'monitor': 'metric_to_track'
to my returned dict since then mypy complainsSuggested fix
I suggest to replace
from utilities/types.py with
and
with
What version are you seeing the problem on?
v2.4
How to reproduce the bug
No response
Error messages and logs
Environment
Current environment
More info
No response
The text was updated successfully, but these errors were encountered: