Lightning-AI/pytorch-lightning · error · MisconfigurationException

Unsupported parameter value `Timer(interval={interval})`. Po

Error message

Unsupported parameter value `Timer(interval={interval})`. Possible choices are: {', '.join(set(Interval))}

What it means

Timer's `interval` argument determines when the time budget is checked (on epoch end vs step end) and must be one of the Interval enum values ('epoch' or 'step'). Any other string or type raises this MisconfigurationException in __init__.

Source

Thrown at src/lightning/pytorch/callbacks/timer.py:107

    ) -> None:
        super().__init__()
        if isinstance(duration, str):
            duration_match = re.fullmatch(r"(\d+):(\d\d):(\d\d):(\d\d)", duration.strip())
            if not duration_match:
                raise MisconfigurationException(
                    f"`Timer(duration={duration!r})` is not a valid duration. "
                    "Expected a string in the format DD:HH:MM:SS."
                )
            duration = timedelta(
                days=int(duration_match.group(1)),
                hours=int(duration_match.group(2)),
                minutes=int(duration_match.group(3)),
                seconds=int(duration_match.group(4)),
            )
        elif isinstance(duration, dict):
            duration = timedelta(**duration)
        if interval not in set(Interval):
            raise MisconfigurationException(
                f"Unsupported parameter value `Timer(interval={interval})`. Possible choices are:"
                f" {', '.join(set(Interval))}"
            )
        self._duration = duration.total_seconds() if duration is not None else None
        self._interval = interval
        self._verbose = verbose
        self._start_time: dict[RunningStage, Optional[float]] = dict.fromkeys(RunningStage)
        self._end_time: dict[RunningStage, Optional[float]] = dict.fromkeys(RunningStage)
        self._offset = 0

    def start_time(self, stage: str = RunningStage.TRAINING) -> Optional[float]:
        """Return the start time of a particular stage (in seconds)"""
        stage = RunningStage(stage)
        return self._start_time[stage]

    def end_time(self, stage: str = RunningStage.TRAINING) -> Optional[float]:
        """Return the end time of a particular stage (in seconds)"""
        stage = RunningStage(stage)

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Use interval='epoch' or interval='step' (from lightning.pytorch.callbacks.timer.timer.Interval)
  2. Check valid values: from lightning.pytorch.callbacks.timer import Interval; print(set(Interval))

Example fix

# before
timer = Timer(duration="00:00:10:00", interval="batch")
# after
from lightning.pytorch.callbacks.timer import Interval
timer = Timer(duration="00:00:10:00", interval=Interval.step)  # or "step"
Defensive patterns

Strategy: validation

Validate before calling

from lightning.pytorch.callbacks.timer import Interval
def norm_interval(v):
    v = str(v).lower()
    assert v in set(Interval), f'interval must be one of {set(Interval)}'
    return v
Timer(interval=norm_interval(cfg.interval))

Type guard

def is_valid_interval(v) -> bool:
    from lightning.pytorch.callbacks.timer import Interval
    return v in set(Interval)

Prevention

When it happens

Trigger: Timer(interval='batch'), Timer(interval='epochs'), Timer(interval=1), or a typo like 'Step'.

Common situations: Assuming 'batch' is valid because steps are batches; case sensitivity surprises.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/465570002796643c. Report an issue: GitHub.