Repository navigation
Conversation
hao-aaron
force-pushed
the
lp/l2-megamoe-nvfp4-scales
branch
from
November 7, 2026 00:15
607a250 to
4ba1650
Compare
hao-aaron
marked this pull request as ready for review
November 7, 2026 00:29
hao-aaron
requested review from
AndreasKaratzas,
DarkLight1337,
bnellnm,
mgoin,
pavanimajety,
wzhao18,
ywang96 and
zyongye
as code owners
November 7, 2026 00:29
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
hao-aaron
force-pushed
the
lp/l2-megamoe-nvfp4-scales
branch
from
November 11, 2026 00:45
4ba1650 to
60667e9
Compare
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
…ading DeepGemmMegaMoEExperts combined NVFP4 global scales inside the weight loader: the L2 activation scale was a running max over a CPU copy of every expert's w2_input_scale, w1 and w3 weight_scale_2 were paired through loader state and both written into one slot, and block scales went through repeat_interleave and clone even when nothing is expanded. A load-plan trace cannot replay any of that. Each checkpoint tensor now lands in its own slot with a view and copy_: w13_weight_scale_2 is (2, experts) for w1 and w3, so its w1 row is the contiguous L1 alpha the kernel reads; w2_input_scale holds every logical expert on every rank; block scales are a view chain unless the checkpoint granularity is coarser than the kernel's. A new process_weights_after_loading checks the w1/w3 pair and sets l2_activation_scale from the max; it reruns on every reload. _l2_alpha is marked weight_loader_numel = 0 so layerwise reload does not wait for it. Passing the L2 activation scale to the kernels as a tensor is left for later. Kernel-facing tensors match base at cold start when the w1 and w3 global scales are equal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com>
The load plan's trace treats a dtype view that changes the element size as a copy, so packing the 1-byte block scales into int32 before the copy made every routed weight_scale name a fallback. Both sides are now byte views, (rows, K / 4, 4), and the copy moves the same bytes. The clone for non-contiguous or misaligned scales is gone with it. The routed-loader test now builds a load plan: every routed name is direct, and planned and unplanned updates match a cold start. It replaces the FakeRDTTensor trace and the direct-reload test. Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ise reload Layerwise reload counts the elements each loader copies to decide when a layer is complete. Block scales are now copied through a uint8 view of the int32 parameter, so each copy counted four times its int32 elements, the layer was processed before its last loads arrived and those were dropped. The scale parameters now declare their load size in bytes. The layerwise test loads the block scales last and checks the whole kernel layout, so an early processing fails it; it covers MXFP4 too. The w1/w3 mismatch error names the local slot (EPLB may have moved experts), and the meta test keeps only the post-load processing check. Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shuffled-load helper always runs post-load processing (no caller skipped it). The layerwise test keeps the kernel layout and L2 scale checks and drops the global-scale placement checks the load test makes; the w1/w3 mismatch test drops its placement checks too. Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- w2_weight_scale_2 gets a positive dummy value like the other scales. - get_expert_weights builds the EPLB views in one loop. - _pack_scale is now _expand_scale: it no longer packs into int32. - The _create_weights docstring names w2_input_scale as not moved. - Tests: w1 and w3 weight_scale_2 land in their own rows and the mismatch error names both values; the layerwise test checks can_load() instead of patching a private function. Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an test Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unknown shard id now raises instead of landing in the w3 row. Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com>
SM90 repacks MXFP4 routed shards in the loader, so those names are fallbacks there; the new tests follow the SM90 kernel gate of the other kernel-layout tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com>
hao-aaron
force-pushed
the
lp/l2-megamoe-nvfp4-scales
branch
from
November 16, 2026 19:56
60667e9 to
c18b452
Compare
Collaborator
Author
|
/ci run |
|
✅ Triggered Buildkite CI #103234 for commit ℹ️ This PR is 3 commits behind upstream |
aoshen02
approved these changes
Nov 17, 2026
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Aaron Hao <hao-aaron@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Purpose
Part of #64418 (load plan), item L2 (closes RFC item X5 for MegaMoE).
DeepGemmMegaMoEExpertsskipped its_record_global_scalebookkeeping on meta, so after a planned updatel2_activation_scalekept its old value.copy_.process_weights_after_loadingcombines them, and it reruns after every load and reload.Changes
All in
vllm/model_executor/layers/fused_moe/deep_gemm_mega_moe.py:w13_weight_scale_2is now(2, local experts), one row for w1 and one for w3.l1_alpha.w2_input_scaleis now(logical experts,)and is written on every rank, so all ranks agree on the L2 scale. EPLB does not move it.process_weights_after_loading:ValueErroras before, now after loading;l2_activation_scale = max(w2_input_scale) or 1.0;_w2_input_scales,_pending_l1_scalesand_record_global_scale.(rows, K/4, 4)uint8 and the destination is a uint8 view of the int32 kernel layout.repeat_interleaveruns only when the checkpoint scales are coarser than the kernel's, and thecloneis gone.scale_k == 1cases.weight_loader_numelin bytes, which is what the byte-view copies count;_l2_alphadeclares 0, since no loader writes it.1e-3,1e-3,1.0): w1 and w3 match and the L2 scale stays at 1.Known limitations
l2_activation_scaleis still a host float passed by value to the prepare kernel and to DeepGEMM. A reload updates it, but graphs captured earlier keep the old value, along with the_l2_alphathey compute from it. This holds for RL starts from--load-format dummy. The fix is to pass it as a device tensor, which is [RFC]: Direct Weight Reload for RL Training #54477 F16 and needs [SM100] NVFP4 MegaMoE: take the L2 activation scale as a device tensor DeepGEMM#49. The graph row in the audit table shows this.plan_loads(pre-existing, outside this file).weight_global_scaleinto1 / x, which makes those names fallbacks.unflattenand dtype-changing destination views are not in its op allowlist. It fails loudly at engine init, and base failed there too (repeat_interleave).w13_weight_scale_2went from(e,)to(2, e)andw2_input_scalefrom(e,)to(logical,). Tensors exported in the old shapes do not reload into the new ones.Test Plan
tests/kernels/moe/test_deep_gemm_mega_moe.py:l2_activation_scalecovers every logical expert and follows a reload;w13_weight_scale_2rows;tests/kernels/moe/test_deep_gemm_mega_moe.pyandtests/models/test_minimax_m3_mega_moe.py.deep_gemm_mega_moe):VLLM_RELOAD_MODE=directwith the load plan on;l2_activation_scalefloat, is compared with a fresh server started on the last checkpoint.Test Result
tests/kernels/moe/test_deep_gemm_mega_moe.py+tests/models/test_minimax_m3_mega_moe.py, 129 passed.l2_activation_scale(fresh 2.0)l2_activation_scale×114,_l2_alpha×114_l2_alpha(captured graphs, F16)w2.input_global_scaleis planned direct, the loader sees meta, and the L2 scale stays at its cold-start value. With this PR the same name is direct and post-load processing recomputes the scale.(1/16) / x). There the loader sees real values, so main'sl2_activation_scalewas refreshed too. This PR passed eager there as well, and with CUDA graphs both had the same 114_l2_alphamismatches.Cold-start A/B
Setup: A = main at this PR's base (10c8574), B = this PR (4ba1650). Both arms are Python overlays on the same nightly wheel (7cf31d2, 24 commits behind the base; the only C++ change in those commits is a ROCm binding). Each row runs on one node, with the arms back to back.
vllm bench serve, random dataset, 1024 in / 256 out, concurrency 64.DeepGemmMegaMoEExpertswas built with the expected weight format. A probe that is identical in both arms prints this line. All rows passed.deep_gemm_mega_moe(GB200, TP4 EP)--gpu-memory-utilization 0.85)--gpu-memory-utilization 0.85 --max-num-seqs 256)--use-chat-completions --max-tokens 2048andreasoning_effort: low. Through plain completions, both arms degenerate on main at this base (0.08 on arm A), while chat answers correctly.--gpu-memory-utilization 0.9, arm A (main) runs out of memory during the update, so this row uses 0.85 in both arms.Inferact/MiniMax-M3-NVFP4-V2is a ModelOpt NVFP4 checkpoint, and MiniMax-M3 MegaMoE requiresmoe_quant_algo: NVFP4, which only the MXFP8-format checkpoints set, so it cannot select this backend.Inferact/Minimax-M3-NVFP4has the same format as M3.1-Flash and runs on MegaMoE, but it scores about 0.03 on GSM8K in both arms, so it was dropped for M3.1-Flash. One A/B pass gave 0.0281 → 0.0394, 4053 → 4026 tok/s and KV cache 2.490M in both arms.step5/nvidia/mega_moe.py,muse_spark/nvidia/mega_moe.py), which do not useDeepGemmMegaMoEExperts, and this PR does not change them.AI assistance (Claude Code) was used; the submitter reviews every changed line.
🤖 Generated with Claude Code