fix(megatron): correct rollout weight reload, resume offsets and sampler seed - #10113
Open
taking-lying-flat wants to merge 1 commit into
Open
Conversation
Normalize vLLM reload devices and propagate post-load errors in the Megatron colocate path. Convert persisted rollout sample counts to prompt offsets and honor data_seed in both sampler shuffling paths. Signed-off-by: taking-lying-flat <1615405@qq.com>
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.
PR type
PR information
Fixes #10098 and #10099 with changes to four production files.
Megatron colocated weight reload passes an integer device ordinal into vLLM's post-load processing, which expects a
torch.device. The existing exception handler hides this failure. Normalize the device and enable strict error propagation for the Megatron caller. Older vLLM releases without the helper retain the compatibility skip; errors inside an existing helper propagate in strict mode. Other callers retain non-strict behavior.The on-policy checkpoint counts generated training samples, while the dataloader indexes unrepeated prompts. Convert the offset at dataloader construction for GRPO/GKD, without modifying the persisted counter, and reject offsets not divisible by
num_generations. For example, 32 consumed rollout rows with four generations correspond to eight prompt rows. GKD currently forcesnum_generations=1, so its conversion is a no-op.Pass
data_seedinto the random sampler and useseed + epochin both sharding branches, including length grouping. The optional sampler argument defaults to zero for existing direct callers.Compatibility note: honoring
data_seedchanges the shuffle order used by old checkpoints, including non-on-policy callers of this sampler. Seed zero reproduces the old sampler permutation only if dataset ordering is identical; changingdata_seedcan also affect upstream dataset preparation. This patch does not restore rollout buffers or guarantee identical generation/RNG state after a resume.Experiment results
Validation scripts were kept local; the PR contains production code only.
0.1.dev564+ga3561ef8e.d20260823.pre-commit run --files swift/rlhf_trainers/utils.py swift/megatron/trainers/rollout_mixin.py swift/megatron/trainers/base.py swift/megatron/trainers/batch_sampler.py: passed.git diff --check: passed.No full distributed Megatron training run or NPU hardware validation was performed.