Repository navigation
Fix delayed learning-rate backoff after loss-spike rollback - #307
ramanathan831 wants to merge 3 commits into
Conversation
Signed-off-by: Ramanathan Arunachalam <rarunachalam@nvidia.com>
|
Review of In Minimal CPU reproduction using this PR's callback: parameter = torch.nn.Parameter(torch.ones(1))
optimizer = torch.optim.AdamW([parameter], lr=0.01)
scheduler = torch.optim.lr_scheduler.LambdaLR(optimizer, lambda step: 1.0)
optimizer.step()
scheduler.step()
guard = LossSpikeRollback(enabled=True)
guard._scale_lr(optimizer, scheduler, 0.5)
assert optimizer.param_groups[0]["lr"] == 0.004
assert scheduler.get_last_lr()[0] == 0.01
assert scheduler.state_dict()["_last_lr"][0] == 0.01This has an actual observability consumer: the existing LR logger reads Could you please synchronize the affected scheduler's reported/cached rates after changing optimizer groups, and add tests asserting agreement between optimizer LR, Validation: the 17 existing regression cases passed when executing the actual functions in an isolated CPU harness (package-level logging/base-class imports isolated); the reproduction above still shows the mismatch. No full training or GPU rerun was performed. The behavioral fix should remain limited to explicitly enabled rollback runs. |
|
Concrete implementation request following the LR-state review: After applying the optimizer-group LR ratio, please refresh each underlying scheduler's cached/reporting state from its own optimizer groups, for example: for sched in schedulers:
sched._last_lr = [
group["lr"] for group in sched.optimizer.param_groups
]Place this after the group-rate adjustment in the scheduler branch of This is a narrowly scoped consistency fix, not a request to change unrelated training or scheduler behavior. |
Signed-off-by: Ramanathan Arunachalam <rarunachalam@nvidia.com>
|
Addressed the LR reporting/state review and concrete follow-up in 8986409. After the optimizer-group adjustment, The regressions cover:
See This addresses the reporting/state inconsistency without claiming that every resume path previously consumed |
When
LossSpikeRollbackruns afteroptimizer.step()andscheduler.step(), changing onlybase_lrsleaves the next optimizer update at the old rate. This PR immediately rescales current optimizer-group rates by the change in the guard's scale, preserving the schedule's current warmup/decay multiplier and gradual recovery.After adjusting the optimizer groups, each underlying scheduler refreshes
_last_lrfrom its own optimizer. This keepsget_last_lr()and serialized scheduler state consistent with the rate consumed by the next update, including multiple optimizers with different parameter-group layouts. It does not call an extrascheduler.step()or advance scheduler counters.The callback remains disabled by default. The backoff/recovery formulas, zero-scale protection, no-scheduler path, and checkpoint/resume policy are unchanged. This fixes the original finding on #291 and the reporting/state review.
Validation:
git diff --checkpassed. AST comparison confirms that the follow-up only adds the cache refresh; other callback behavior and defaults are unchanged.These are small optimizer/callback regressions and L0 checks, not a new full-model training or DCP resume qualification. The save-load tests do not claim persistence of the guard's separate rolling history or change the native containers' existing resume policies.