fix: make post-warmup cosine LR scheduling effective and configurable - #293
Open
yamsam wants to merge 2 commits into
Open
fix: make post-warmup cosine LR scheduling effective and configurable#293yamsam wants to merge 2 commits into
yamsam wants to merge 2 commits into
Conversation
The scheduler named CosineAnnealingWarmUpRestarts actually held the lr
CONSTANT after warmup (post-warmup phase was MultiplicativeLR(lambda=1.0)),
so training collapsed right after warmup: every model peaked in the warmup
epochs and then degraded.
- Add WarmupCosineAnnealingLR: linear warmup then real cosine decay to
eta_min over the remaining epochs (matches original planTF).
- Rename the legacy behavior to WarmupConstantLR (accurate name), kept for
backward-compatible reproduction of pre-existing runs.
- Keep CosineAnnealingWarmUpRestarts as an alias bound to the exact legacy
(constant) behavior so existing imports and resumed checkpoints reproduce.
- Add build_lr_scheduler dispatch and --lr_schedule_type {cosine,constant}
(default cosine). Training now cosine-decays by default; select "constant"
to reproduce old runs.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Isamu Yamashita <isamu.yamashita@tier4.jp>
Author
yamsam
marked this pull request as ready for review
July 29, 2026 06:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fix the learning-rate schedule so that cosine decay is applied correctly after warmup.
The previous
CosineAnnealingWarmUpRestartsimplementation usedMultiplicativeLR(lambda=1.0)after warmup. Despite its name, it therefore keptthe learning rate constant instead of applying cosine annealing.
This PR introduces a real linear-warmup → cosine-decay schedule while preserving
the previous behavior for backward-compatible experiments.
Based on
dev.Changes
Scheduler behavior
WarmupCosineAnnealingLR: linear warmup followed byCosineAnnealingLR.WarmupConstantLR.CosineAnnealingWarmUpRestartsas an alias for the legacy constantimplementation to preserve existing imports.
build_lr_scheduler(...)to selectcosineorconstant.cosine schedule. The legacy step-down remains active only in
constantmode.Resume behavior
when resuming from a checkpoint.
learning rate.
updates.
Configuration
The following options are available through
TrainConfigandtrain_predictor.py:lr_schedule_typecosinecosineor legacyconstantlearning_rate1e-4warm_up_epoch5lr_start_factor0.1lr_eta_min1e-6lr_cosine_t_max00selects the remaining epochs automaticallylr_scheduler_intervalepochepochor perbatchWhen
lr_scheduler_interval=batch, warmup duration, explicitT_max, andresume progress are converted from epochs to optimizer steps using the training
DataLoader length.
The legacy final-phase parameters remain unchanged.
Behavior change and compatibility
--lr_schedule_type constant.CosineAnnealingWarmUpRestartscontinue to work andretain the previous warmup → constant scheduler behavior.
--lr_schedule_type constant.Verification
15 passedstart_factor,eta_min,T_max, and batch-level schedulerupdates with a mini-dataset training run.