fix: name the config key when step scheduler is missing step_size

Without step_size, StepLR raises 'missing 1 required positional argument',
which is Python-level phrasing that does not tell a config author the value
belongs under lr_scheduler_params. Raise with the config path instead.

Deliberately an error rather than a default: step_size determines the shape
of the entire lr curve, so a guessed value would train to completion and
quietly produce a worse result with no signal anything was wrong.
This commit is contained in:
Rasaboun 2026-08-07 10:31:47 +02:00
parent 8c72f4df00
commit 6068a3cd43
No known key found for this signature in database
GPG Key ID: EA0A25A69C89B7E5
1 changed files with 5 additions and 0 deletions

View File

@ -24,6 +24,11 @@ def get_lr_scheduler(
# StepLR decays purely on step_size/gamma and has no notion of run
# length, so drop the total_iters the trainer injects.
kwargs.pop('total_iters', None)
if 'step_size' not in kwargs:
raise ValueError(
"lr_scheduler 'step' requires lr_scheduler_params.step_size "
"(number of steps between each lr decay)"
)
return torch.optim.lr_scheduler.StepLR(
optimizer, **kwargs