Make the WarmupCosineLR ratio flags reach the config - #8268
Open
vineethsaivs wants to merge 2 commits into
Open
Conversation
`add_tuning_arguments` declares `--warmup_min_ratio` and `--cos_min_ratio`,
but `get_config_from_args` sent every schedule that is not LRRangeTest or
OneCycle through `override_warmupLR_params`. Both flags were therefore
dropped, and the config came back carrying `warmup_min_lr`/`warmup_max_lr`
instead, which `WarmupCosineLR.__init__` does not accept:
TypeError: WarmupCosineLR.__init__() got an unexpected keyword argument
'warmup_min_lr'
Give WarmupCosineLR its own params builder, and stop `get_lr_from_config`
reading `warmup_max_lr` for it. It scales each param group's own lr by a
ratio, so its params hold no learning rate at all, and that lookup raised
KeyError on any config written for this schedule.
Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
vineethsaivs
requested review from
loadams,
tjruwase and
tohtana
as code owners
August 17, 2026 17:17
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
sfc-gh-truwase
approved these changes
Aug 20, 2026
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.
add_tuning_argumentsdeclares--warmup_min_ratioand--cos_min_ratioforWarmupCosineLR, but
get_config_from_argsrouted every schedule that is notLRRangeTestorOneCyclethroughoverride_warmupLR_params. So both flagswere parsed and then dropped, and the config came back carrying the WarmupLR
parameters instead:
Both ratios are gone, and building the scheduler from what is left fails,
because
WarmupCosineLRhas no min/max lr at all:WARMUP_MIN_RATIOandCOS_MIN_RATIOwere already defined next to the otherconfig keys, so only the plumbing was missing.
get_lr_from_confighad the mirror-image problem: it falls through tolr_params[WARMUP_MAX_LR]for anything that is notLRRangeTestorOneCycle. For WarmupCosineLR that returned an unrelated WarmupLR default ona CLI-built config, and raised
KeyError: 'warmup_max_lr'on a configactually written for this schedule. WarmupCosineLR scales each param group's
own lr by a ratio, so there is no learning rate in its params to read, and it
now says so instead.
The JSON config path was never affected:
engine._configure_lr_schedulercalls
scheduler(optimizer, **scheduler_params)straight from the configfile, so
"scheduler": {"type": "WarmupCosineLR", "params": {"warmup_min_ratio": 0.1}}has always worked. Only the
add_tuning_argumentsCLI helper is fixed here.Other schedules are untouched.
LRRangeTest,OneCycle,WarmupLRandWarmupDecayLRproduce the same params and the sameget_lr_from_configanswer as before, and
test_other_schedules_keep_their_config_paramspinsthat.
Not included, so as to keep this to one thing:
TOTAL_NUM_STEPSisdefined but unused, and neither
WarmupDecayLRnorWarmupCosineLRcan bebuilt from
get_config_from_argsoutput alone because both needtotal_num_steps, which has no CLI flag. Callers pass it themselves today.Happy to add that separately if you would like it plumbed.
Tests
tests/unit/runtime/test_lr_schedulers.pygains three plain (non-distributed)tests next to the existing ones:
test_warmup_cosine_lr_config_from_args_carries_the_ratiostest_warmup_cosine_lr_has_no_lr_in_its_config_paramstest_other_schedules_keep_their_config_paramsDeepSpeed does not build on this machine (macOS, no CUDA), so I ran the three
new test bodies against the unmodified
lr_schedules.pyfrom master andagainst the patched one, loading the module directly:
The one that passes on both sides is the no-regression control.
yapf --style .style.yapf --diffis clean on both changed files, and neitheradds a line over the 119 column limit.