[megatron] rebuild weight conversion tasks per sync to prevent stale PP-collective caches with bucketing#1345
Merged
erictang000 merged 2 commits intoNovaSky-AI:mainfrom Mar 19, 2026
Conversation
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
devpatelio
pushed a commit
that referenced
this pull request
Mar 20, 2026
…PP-collective caches with bucketing (#1345) ## Summary - Bucketed weight sync reused `WeightConversionTask` objects (and their mapping caches) across sync cycles, causing incorrect vLLM weight updates for DeepSeek-V3 style models (like Moonlight-16B-A3B, or GLM-4.7-Flash) with PP > 1 (for both LoRA and full finetuning). The mapping objects cache PP-collective metadata that becomes stale across train/offload/reload cycles. - Fix: store only the bucket index structure (which task indices go in which bucket) once, and rebuild fresh tasks with clean mapping objects on each `extract_weights()` call. This preserves packed-broadcast performance while ensuring correct PP collectives every sync. This manifested in extremely unstable training + reward collapsing for Deepseek-v3 style models with megatron. ## Test plan - [x] Moonlight-16B with PP=2: reward increases without significant weight sync time regression ## Results ### Moonlight-16B-A3B GSM8k Before in purple, after the fix in blue: <img width="315" height="246" alt="image" src="https://github.com/user-attachments/assets/9a7119af-aea8-4b81-888f-f05cd3865c99" /> <img width="318" height="242" alt="image" src="https://github.com/user-attachments/assets/b899766f-9a7e-43fc-98f9-2f856dc04c3c" /> Weight sync timing (~10s after, ~8s before): <img width="317" height="246" alt="image" src="https://github.com/user-attachments/assets/ed46cdbc-9b95-4533-bb5f-416db56a2847" /> ### GLM-4.7-Flash GSM8k Before in red, after the fix in tan (GLM with LoRA) <img width="337" height="525" alt="image" src="https://github.com/user-attachments/assets/e647d6f4-42a9-4317-99d4-e3d1d940b038" /> Weight sync timing (~15 after, ~12 before): <img width="331" height="239" alt="image" src="https://github.com/user-attachments/assets/cc98f4e9-314c-462c-ab7f-80b29bc96f70" /> <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/novasky-ai/skyrl/pull/1345" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.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.
Summary
WeightConversionTaskobjects (and their mapping caches) across sync cycles, causing incorrect vLLM weight updates for DeepSeek-V3 style models (like Moonlight-16B-A3B, or GLM-4.7-Flash) with PP > 1 (for both LoRA and full finetuning). The mapping objects cache PP-collective metadata that becomes stale across train/offload/reload cycles.extract_weights()call. This preserves packed-broadcast performance while ensuring correct PP collectives every sync.This manifested in extremely unstable training + reward collapsing for Deepseek-v3 style models with megatron.
Test plan
Results
Moonlight-16B-A3B GSM8k
Before in purple, after the fix in blue:


Weight sync timing (~10s after, ~8s before):

GLM-4.7-Flash GSM8k
Before in red, after the fix in tan (GLM with LoRA)

Weight sync timing (~15 after, ~12 before):
