fix(train): raise clear error when computed train_iters is 0 - #2366
Draft
Xuan-1998 wants to merge 1 commit into
Draft
fix(train): raise clear error when computed train_iters is 0#2366Xuan-1998 wants to merge 1 commit into
Xuan-1998 wants to merge 1 commit into
Conversation
When num_rollout * rollout_batch_size * n_samples_per_prompt is smaller than global_batch_size, the floor division in get_optimizer_param_scheduler computes train_iters = 0. The zero propagates into Megatron's OptimizerParamScheduler, which dies with a bare 'assert self.lr_decay_steps > 0' during actor bring-up, giving no hint about which config knob is wrong. Raise a ValueError at the point where slime computes train_iters, naming the four inputs, their product, and how to fix the config. No behavior change for valid configs. The num_rollout == 0 eval-only path (THUDM#2296) returns before this function is called and is unaffected; this covers the remaining 0 < product < global_batch_size case.
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 this fixes
Launching training with a rollout configuration whose total sample count is smaller than the global batch size, for example:
computes
train_iters = 2 * 8 * 8 // 256 = 0inget_optimizer_param_scheduler(slime/backends/megatron_utils/model.py). The zero propagates into Megatron'sOptimizerParamScheduler, which fails during actor bring-up with a bareAssertionErroratmegatron/core/optimizer_param_scheduler.py(assert self.lr_decay_steps > 0, no message). Nothing in the traceback points at the slime config knobs that caused it.What changes
A
ValueErroris raised right aftertrain_itersis computed, at the point where slime owns the math. The message names the four inputs with their values, shows the product versusglobal_batch_size, and says how to fix the config:No behavior change for valid configs.
Prior art
num_rollout == 0returns frominitialize_model_and_optimizerbeforeget_optimizer_param_scheduleris called, so that path is unaffected by this change.num_rollout == 0and was addressed by fix(train): skip optimizer and scheduler for eval-only #2296.num_rollout > 0butnum_rollout * rollout_batch_size * n_samples_per_prompt < global_batch_size, was still unguarded; the validation inslime/utils/arguments.pyonly checks the batch math when--num-steps-per-rolloutis set.Test
tests/test_train_iters_validation.pyis a CPU unit test following the megatron-stubbing pattern oftests/test_model_provider_freeze.py: it loadsmodel.pywith stubbedmegatron.*modules and callsget_optimizer_param_schedulerdirectly. One case asserts theValueErrornames all four inputs; one case asserts a valid config still computestrain_itersand constructs the scheduler with the same step counts as before.