fix: support eval-only mode (--num-rollout 0)#2109
Open
EazyReal wants to merge 1 commit into
Open
Conversation
train.py advertises an eval-only path (num_rollout == 0 with eval_interval set), but the optimizer scheduler is still constructed during model init. With num_rollout == 0 the estimated train_iters is 0, so lr_decay_steps is 0 and Megatron's OptimizerParamScheduler aborts on `assert lr_decay_steps > 0`, making the advertised eval-only path unreachable. Clamp train_iters to >= 1: it only sizes the LR-decay schedule and the scheduler is never stepped in eval-only mode, so the exact value is irrelevant. Add a CPU unit test (Megatron stubbed) that reproduces the assertion and registers it in the cpu-unittest CI matrix. Fixes THUDM#1785 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
a658aac to
9e5f530
Compare
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.
What
train.pydocuments an eval-only mode (--num-rollout 0with--eval-intervalset), but it crashes on startup: withnum_rollout == 0the estimatedtrain_itersis0, solr_decay_stepsis0and Megatron'sOptimizerParamScheduleraborts onassert lr_decay_steps > 0— before the eval-only short-circuit intrain.pyis ever reached.Fix
Clamp
train_itersto>= 1. It only sizes the LR-decay schedule, and the scheduler is never stepped in eval-only mode, so the value is irrelevant there; for real training (num_rollout > 0)max(1, …)is a no-op.Adds a CPU regression test (Megatron stubbed, mirroring
tests/test_megatron_argument_validation.py) registered in thecpu-unittestmatrix.Fixes #1785