Repository navigation
[FlyDSL] MegaMoEV2: combine_wire option that every route honours - #8922
Open
MengqingCao wants to merge 3 commits into
Open
MengqingCao wants to merge 3 commits into
MengqingCao wants to merge 3 commits into
Conversation
MengqingCao
marked this pull request as ready for review
November 30, 2026 08:33
This was referenced Nov 30, 2026
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
MengqingCao
force-pushed
the
mengqing/megamoe-combine-wire
branch
from
December 1, 2026 02:51
ef6599c to
5866b97
Compare
GwilliamHu
previously approved these changes
Dec 2, 2026
zufayu
previously approved these changes
Dec 2, 2026
zufayu
force-pushed
the
mengqing/megamoe-combine-wire
branch
from
December 2, 2026 07:23
5866b97 to
7bd83fa
Compare
MengqingCao
force-pushed
the
mengqing/megamoe-combine-wire
branch
from
December 2, 2026 17:42
7bd83fa to
cf389bf
Compare
Contributor
Author
zufayu
previously approved these changes
Dec 3, 2026
GwilliamHu
previously approved these changes
Dec 3, 2026
MengqingCao
force-pushed
the
mengqing/megamoe-combine-wire
branch
from
December 3, 2026 08:40
cf389bf to
4df445b
Compare
MengqingCao
force-pushed
the
mengqing/megamoe-combine-wire
branch
from
December 3, 2026 08:42
4df445b to
593c410
Compare
Adds MegaMoEV2(combine_wire="auto" | "bf16"). "bf16" makes every route the instance builds send BF16 combine rows: the staged route is built with stage2_p2p_quant="none" (an FP8 stage2_p2p_quant raises), and every small-input token bucket gets bf16_rows_always. The large-input kernel combines over FP8 only, so under "bf16" it is not built (large_m_dropped, a rank-0 warning) and its calls take the staged route. "auto" changes nothing. select_mega_moe_config(p2p_quant="none") now drops the FP8-only aligned-pair Stage2 instead of raising; "auto" is unchanged. The routes suite takes --combine-wire; under "bf16" a [WIRE] check fails if any built route can launch a config that sends non-BF16 rows, and the edge cases check that no peer sent FP8 rows. A CPU test covers the aligned-pair fallback. bench_mega_moe_m31.py takes --combine-wire. Co-Authored-By: Claude <[email protected]>
A job takes combine_wire (CLI --combine-wire), passed to MegaMoEV2 and named in the job. The M3.1 profile builds with combine_wire="bf16", as ATOM requests it: at capacity 16384 the staged route then runs the BF16 Stage2 instead of the default FP8 one, so the cache holds the kernels ATOM launches. Co-Authored-By: Claude <[email protected]>
MengqingCao
force-pushed
the
mengqing/megamoe-combine-wire
branch
from
December 3, 2026 08:49
593c410 to
eb2da6d
Compare
zufayu
approved these changes
Dec 4, 2026
GwilliamHu
approved these changes
Dec 4, 2026
…-wire Brings in aiter main (#9129) through the base branch. Co-Authored-By: Claude <[email protected]>
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.
Ready for review. No blocking issues. Top of a stack of three (gh stack), on top of the M3.1 EP4 layout PR; the diff shows only this layer. Replaces #8918 (same commit).
Why
A caller whose model needs a BF16 combine wire cannot ask MegaMoEV2 for one. At capacity 1024 and up the staged route sends FP8 rows, the small-input kernel switches to FP8 rows past a row threshold, and the large-input kernel is FP8 only. ATOM (ROCm/ATOM#3930) wants to pick the wire per model.
Why MiniMax-M3.1 asks for BF16: it is a numerics-parity choice, not a measured FP8 failure.
nvfp4_mega_moe) also combines in BF16 with FP32 accumulation."bf16"the large-input route is not built, so calls above the small-input capacity take the staged route. M3.1's decode steps fit the small-input capacity, so its decode does not hit this.What changed
MegaMoEV2(combine_wire="auto" | "bf16")."auto"changes nothing."bf16"the staged route is built withstage2_p2p_quant="none"; an FP8stage2_p2p_quantraises. Every small-input bucket getsbf16_rows_always(SmallMRuntime(bf16_wire=True))."bf16"(large_m_dropped, a rank-0 warning); its calls take the staged route.select_mega_moe_config(p2p_quant="none")drops the FP8-only aligned-pair Stage2 instead of raising.combine_wire(--combine-wire), and the M3.1 profile builds with"bf16", as ATOM requests. At 16384 that is a different staged Stage2.--combine-wire: under"bf16",[WIRE]fails if any built route can launch a non-BF16 config, and the edge cases fail if a peer sent FP8 rows.Review focus
"bf16", calls above the small-input capacity go staged rather than to the large-input route (Dev record, Decided).Testing
Under
"bf16"no built route can send a non-BF16 row, and every route still matches the reference.ef6599c43(kernel code): routes suite--combine-wire bf16m31 a8w4 and a4w4 64 PASS each, V4.1-Flash EP4 58 PASS."auto"V4.1-Flash EP4 57 PASS.5866b970b: M3.1 AOT replay 4 ok,--check4 ok, an M3.1 runtime ran every bucket from the cache with compiles forbidden. Route-plan 218 and AOT driver 5 passed. ruff, black clean.Follow-ups
Dev record
Found. none
Decided.
"bf16"the large-input route is dropped and its calls run staged with a BF16 wire. A BF16 large-input kernel is new kernel work; refusing would break every caller above 512 rows a rank. The cost is staged time on those calls only (V4.1-Flash EP4 at 8192: large-input route not built)."bf16"with an FP8stage2_p2p_quantraises instead of silently overriding it.Surprised. none
Left undone. Not run: EP8 and EP2 layouts, MI300X, MI250X.
"auto"timing against main was not re-measured on this head. The pre-merge measurement on #8623's head (MengqingCao#4) found -1.4% to +1.0%.Evidence
4 x MI355X (gfx950), gpool lease on pit2-p03-g07 GPUs 4-7, image
mengqing-108/agx:c2f06e01-mega-a40489a9e(FlyDSL 0.5.3), this tree'saiter/ops/flydsl,aiter/aot,aiter/utility,op_tests/multigpu_testsandtestsover the image's aiter. Fromop_tests/multigpu_tests:CPU:
test_bf16_wire_drops_aligned_pair_stage2(new) checks thatp2p_quant="none"never returns the aligned-pair Stage2, on layouts where"auto"tunes it. Pre-merge revert-red on the same code: withoutbf16_wire=combine_wire == "bf16",[WIRE]lists the small-input buckets and the suite fails.PR Self-Review
Reviewed revision
133408e927b9Behavior and intent
MegaMoEV2(combine_wire="auto" | "bf16")is new. Under"bf16":stage2_p2p_quant="none"; an FP8stage2_p2p_quantraises.SmallMRuntime(bf16_wire=True)).large_m_dropped, rank-0 warning), and its calls go staged.select_mega_moe_config(p2p_quant="none")now drops the FP8-only aligned-pair Stage2 instead of raising."auto"changes nothing. Before this PR, a caller could not get a BF16 combine wire: the staged route sends FP8 at capacity 1024 and up, and the small-input kernel switches to FP8 past a row threshold. ATOM (ROCm/ATOM#3930) needs to choose the wire per model.Validation and unverified scope
Hardware and config: 4 x MI355X (gfx950, pit2-p03-g07 GPUs 4-7), image
mengqing-108/agx:c2f06e01-mega-a40489a9e(FlyDSL 0.5.3), the tree'saiter/ops/flydsl,aiter/aot,aiter/utility,op_tests/multigpu_testsandtestscopied over the image's aiter. Commands run fromop_tests/multigpu_tests.GPU route tests at
ef6599c43. The kernel code is the same as atef6599c43, where the GPU tests ran; the AOT commits change onlyaiter/aot/flydsl/mega_moe.pyandtests/test_aot_drivers.py.Routes suite
--network v41_flash --quant a8w4 --combine-wire bf16 --time-bs 104: 58 PASS.[WIRE] non-bf16 routes=[] PASS; the large-input route is not built, and the call at 513 rows runs staged (relL2 0.0520).Routes suite
--network m31 --quant {a8w4,a4w4} --mtpr 1024 --combine-wire bf16 --check-time-acc --time-bs 104,144,152: 64 PASS each,[WIRE]PASS,fp8_peers=0on every edge case.Routes suite
--network v41_flash --quant a8w4 --time-bs 104("auto"): 57 PASS.python -m pytest tests/test_mega_moe_gfx950_route_plan.py: 218 passed;tests/test_aot_drivers.py::MegaMoEProductionJobsTest: 5 passed (PA-Gluon import stubbed on the CPU node).AOT runs: pit2-p03-g08 (functional node), same image,
GPU_ARCHS=gfx950, the AOT cache (AITER_FLYDSL_AOT_CACHE_DIR) and FlyDSL runtime cache (FLYDSL_RUNTIME_CACHE_DIR) on shared storage.python -m aiter.aot.flydsl.mega_moe --experts-per-rank 32 --world-size 4 --topk 4 --model-dim 6144 --inter-dim 3072 --swiglu-limit 7 --act swigluoai --combine-wire bf16 --mtpr 512 16384: replay 4 ok, 0 failed. The same with--checkfrom a fresh container: 4 ok.The same
--checkwith--combine-wire auto: 2 ok (512), 2 failed (16384, the FP8 staged Stage2). So the BF16 build is the one ATOM needs.GPU first use (g08 GPUs 0-3,
FLYDSL_RUNTIME_RUN_ONLY=1, both caches):MegaMoEV2for M3.1, routed,combine_wire="bf16", a8w4 and a4w4 at MTPR 512 and 16384. One forward at each of max_tokens 1-512 (small-input) and 513-16384 (staged): all ran, no AOT miss.black 26.10.1 and ruff 0.16.0 clean.
Rebased on main at
1f9a7fb50, which merged [FlyDSL] MegaMoEV2 DeepSeek-V4.1-Flash: FP8 shared expert computed inside the MegaMoE kernels (shared_in), standalone on main #8878 (V4.1-Flash shared_in) into the same small-input kernel builder and routes suite:compile_mega_moe_stage1takesbf16_wireandv41_shared(keyword-only), the kernel name carries both suffixes, and the routes suite takes--network m31beside--shared-in-only. At this head, over the image's aiter on CPU:tests/test_mega_moe_gfx950_route_plan.py+tests/test_mega_moe_gfx950_shared_in.py264 passed; black and ruff clean. The GPU runs above predate the rebase.Rebased on main at
926205e73([HIP] [FlyDSL] DeepSeek-V4.1-Flash: MegaMoEV2 DSpark draft BF16 return and small-input route, EP8 / EP4 small-input bucket tables, H64 attention scalar loads #9076, V4.1-Flash DSpark draft layout; Kimi-K2.6 EP8 small_m / large_m), with [FlyDSL] MegaMoEV2: MiniMax-M3.1 EP4 layout on the fused small-input route #8921 under it.SmallMRuntime(bf16_wire=True)now sets main'sFusedStage1Knobs.bf16_rows_alwayson every bucket ([FlyDSL] MegaMoEV2: MiniMax-M3.1 EP4 layout on the fused small-input route #8921 dropped its own knob for it), and the[WIRE]check reads that knob. [HIP] [FlyDSL] DeepSeek-V4.1-Flash: MegaMoEV2 DSpark draft BF16 return and small-input route, EP8 / EP4 small-input bucket tables, H64 attention scalar loads #9076's own aligned-pair fallback for its BF16-return layouts sits beside this PR'sp2p_quant="none"one; both stay. At this head, over the image's aiter on CPU:tests/test_mega_moe_gfx950_route_plan.py+tests/test_mega_moe_v41_draft_layout.py+tests/test_mega_moe_v41_small_knobs.py307 passed,MegaMoEProductionJobsTest6 passed; black 26.10.1 and ruff clean. The GPU and AOT runs above predate this rebase; the M3.1 small-input kernels are renamed (_b16rafor_bw), so an AOT cache built before it misses them.Merged aiter main (at
66da04555, which has [Hotfix] Align ReLU2 dispatch with legacy and refresh snapshots #9129, the ReLU2 dispatch hotfix) into the branch instead of rebasing, so the approvals stay. The Heavy CI'stests/test_moev2_differential.py::test_dispatch_plans_match_legacyfailure came from that missing hotfix. The PR diff is unchanged. At this head, over the image's aiter on CPU: the MegaMoE route-plan, V4.1-Flash draft-layout and small-knob tests andMegaMoEProductionJobsTestpass as before; black and ruff clean.Unverified:
"auto"timing against main was not re-measured at this head. On [FlyDSL] [CI] [MoE] MegaMoEV2: fully fused A4W4 routes, A8W4 performance optimizations, capacity 32768, rank-shared AOT #8623's pre-merge head (MegaMoEV2: combine_wire option that every route honours MengqingCao/aiter#4) it was -1.4% to +1.0%.PR-specific question
test_mega_moe_v2.py --suite routes --combine-wire bf16: before this PR,MegaMoEV2(combine_wire=...)raisesTypeError.[WIRE]fails if any built route can launch a config that sends non-BF16 rows. The edge cases fail if a peer's published flag says it sent FP8 rows. No existing test checks each route's combine-row dtype.tests/test_mega_moe_gfx950_route_plan.py::test_bf16_wire_drops_aligned_pair_stage2fails before:select_mega_moe_config(p2p_quant="none")raised on the aligned-pair buckets.bench_mega_moe_m31.py:--combine-wirepasses the option through; no pass/fail change.tests/test_aot_drivers.py::test_m31_ep4_profilenow also pinscombine_wire="bf16"; it fails before this commit, which adds the job field.Changed op tests
op_tests/multigpu_tests/test_mega_moe_v2.py:--combine-wire,_non_bf16_wire_routes([WIRE]), and_fp8_peersin the edge cases. Not redundant: they are the only checks that every route sends BF16 under"bf16".op_tests/multigpu_tests/bench_mega_moe_m31.py:--combine-wire, so the bench times the instance as ATOM builds it for M3.1. Not redundant: no other bench takes the option.tests/test_mega_moe_gfx950_route_plan.py(outsideop_tests/):test_bf16_wire_drops_aligned_pair_stage2(CPU).tests/test_aot_drivers.py(outsideop_tests/): the M3.1 profile'scombine_wirecheck.🤖 Generated with Claude Code