Lightning-AI/pytorch-lightning · critical · MisconfigurationException
`configure_optimizers` must include a monitor when a `Reduce
Error message
`configure_optimizers` must include a monitor when a `ReduceLROnPlateau` scheduler is used. For example: {"optimizer": optimizer, "lr_scheduler": scheduler, "monitor": "metric_to_track"} What it means
ReduceLROnPlateau needs a monitored metric to decide when to reduce the LR. If a ReduceLROnPlateau scheduler is configured without a 'monitor' key, Lightning raises MisconfigurationException with an example of the expected dict.
Source
Thrown at src/lightning/pytorch/core/optimizer.py:293
"reduce_on_plateau", isinstance(scheduler["scheduler"], optim.lr_scheduler.ReduceLROnPlateau)
)
if scheduler["reduce_on_plateau"] and scheduler.get("monitor") is None:
raise MisconfigurationException(
"The lr scheduler dict must include a monitor when a `ReduceLROnPlateau` scheduler is used."
' For example: {"optimizer": optimizer, "lr_scheduler":'
' {"scheduler": scheduler, "monitor": "your_loss"}}'
)
is_one_cycle = isinstance(scheduler["scheduler"], optim.lr_scheduler.OneCycleLR)
if is_one_cycle and scheduler.get("interval", "epoch") == "epoch":
rank_zero_warn(
"A `OneCycleLR` scheduler is using 'interval': 'epoch'."
" Are you sure you didn't mean 'interval': 'step'?",
category=RuntimeWarning,
)
config = LRSchedulerConfig(**scheduler)
elif isinstance(scheduler, ReduceLROnPlateau):
if monitor is None:
raise MisconfigurationException(
"`configure_optimizers` must include a monitor when a `ReduceLROnPlateau`"
" scheduler is used. For example:"
' {"optimizer": optimizer, "lr_scheduler": scheduler, "monitor": "metric_to_track"}'
)
config = LRSchedulerConfig(scheduler, reduce_on_plateau=True, monitor=monitor)
else:
config = LRSchedulerConfig(scheduler)
lr_scheduler_configs.append(config)
return lr_scheduler_configs
def _configure_schedulers_manual_opt(schedulers: list) -> list[LRSchedulerConfig]:
"""Convert each scheduler into `LRSchedulerConfig` structure with relevant information, when using manual
optimization."""
lr_scheduler_configs = []
for scheduler in schedulers:
if isinstance(scheduler, dict):
# interval is not in this list even though the user needs to manually call the scheduler becauseView on GitHub (pinned to 9fed5c27d2)
Solutions
- Add 'monitor': '<logged_metric_name>' to the scheduler dict
- Ensure the metric is actually logged via self.log(monitor, ...) or self.log_dict in validation/training
Example fix
# before
return {'optimizer': opt, 'lr_scheduler': torch.optim.lr_scheduler.ReduceLROnPlateau(opt)}
# after
return {
'optimizer': opt,
'lr_scheduler': torch.optim.lr_scheduler.ReduceLROnPlateau(opt),
'monitor': 'val_loss',
}
# and in validation_step: self.log('val_loss', loss) Defensive patterns
Strategy: validation
Validate before calling
from torch.optim.lr_scheduler import ReduceLROnPlateau
if isinstance(scheduler, ReduceLROnPlateau):
assert monitor, "ReduceLROnPlateau requires a monitor" Type guard
def needs_monitor(sched) -> bool:
from torch.optim.lr_scheduler import ReduceLROnPlateau
return isinstance(sched, ReduceLROnPlateau) Prevention
- Always pair ReduceLROnPlateau with a logged validation metric
- Test that the monitored name appears in trainer callback_metrics
When it happens
Trigger: Returning {'optimizer': opt, 'lr_scheduler': ReduceLROnPlateau(opt)} with no 'monitor' key.
Common situations: Copy-pasting a StepLR config and swapping in ReduceLROnPlateau without adding a monitor; not logging the metric referenced by monitor.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Early stopping conditioned on metric `{self.monitor}` which
- `ModelCheckpoint(monitor={self.monitor!r})` could not find t
- The lr scheduler dict must have the key "scheduler" with its
- The "interval" key in lr scheduler dict must be "step" or "e
- The provided lr scheduler `{scheduler.__class__.__name__}` i
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/996f89cab72d45d5.
Report an issue: GitHub.