[feat] Add Qwen3 MoE true-on-policy parity#30
Open
maocheng23 wants to merge 22 commits into
Open
Conversation
This was referenced May 1, 2026
c63c77f to
9c390a1
Compare
3 tasks
9546575 to
57258c8
Compare
ab103f8 to
9c6c2a9
Compare
Co-authored-by: zju-stu-lizheng <lizheng.cs@zju.edu.cn> Co-authored-by: zyxiyy02 <282300612+zyxiyy02@users.noreply.github.com> Co-authored-by: Yi Zhang <1109276519@qq.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: zju-stu-lizheng <lizheng.cs@zju.edu.cn> Co-authored-by: zyxiyy02 <282300612+zyxiyy02@users.noreply.github.com> Co-authored-by: Yi Zhang <1109276519@qq.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: zju-stu-lizheng <lizheng.cs@zju.edu.cn> Co-authored-by: zyxiyy02 <282300612+zyxiyy02@users.noreply.github.com> Co-authored-by: Yi Zhang <1109276519@qq.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: zju-stu-lizheng <lizheng.cs@zju.edu.cn> Co-authored-by: zyxiyy02 <282300612+zyxiyy02@users.noreply.github.com> Co-authored-by: Yi Zhang <1109276519@qq.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: zju-stu-lizheng <lizheng.cs@zju.edu.cn> Co-authored-by: zyxiyy02 <282300612+zyxiyy02@users.noreply.github.com> Co-authored-by: Yi Zhang <1109276519@qq.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- forward.py: single canonical sglang_moe_forward (102 lines) - autograd.py: pure backward wrapper calling shared forward (182 lines) - moe_experts.py: weight-layout adapter only, no forward logic (36 lines) - moe_layer_ext.py: one linear orchestration path (301 lines) - Remove verbose RuntimeError guards, replace with asserts - Remove weight caching (premature optimization) - Consolidate two parallel forward paths into one Net: -574 lines, structurally impossible for forward paths to diverge. Co-authored-by: Cursor <cursoragent@cursor.com>
7ac2a80 to
b0679e2
Compare
6 tasks
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
Adds the Megatron-LM side of the Qwen3-30B-A3B MoE true-on-policy stack.
This PR is one of three coupled PRs that must land together because they share the
qwen3_moe_true_on_policy_v1contract and were validated as one end-to-end stack.Companion PRs:
Target
Bit-identical rollout/train logprob parity for Qwen3-30B-A3B MoE under deterministic decode, with differentiable Megatron backward.
SGLang remains the numerical source of truth. Megatron reproduces the SGLang MoE numerics in training, including deterministic routing/top-k and EP reduction behavior required by the contract.
Main Changes
moe_runner.triton_utilslayout.qwen3_moe_true_on_policy_v1contract.Validation
Latest rebased EP4 E2E on ion7, Qwen3-30B-A3B, 8x H200, run
qwen3-moe-top-ep4-rebased-e2e-260522-ion7-r4:raysubmit_yc4WK8aCKzP4tx1QTP=1, EP=4, ETP=1, CP=2rollout_num_gpus=8,rollout_num_gpus_per_engine=4,SGLang TP=4,SGLang EP=4recompute_logprobs_via_prefill=False,use_rollout_logprobs=False-2.8848648071289062e-05-2.8848648071289062e-05-2.8848648071289062e-05train/train_rollout_logprob_abs_diff = 0.0train/train_rollout_kl = 0.0Local record:
recovery/qwen3_moe_clean/journal/2026-05-22-qwen3-moe-clean-e2e.mdTest Plan
radixark/Megatron-LM:miles-mainstack.