Repository navigation
[FlyDSL] MegaMoEV2: combine_wire option that every route honours - #8918
MengqingCao wants to merge 3 commits into
Conversation
MiniMax-M3.1's experts use SwiGLU-OAI: the gate clamped above and the up projection to +-swiglu_limit, then gate * sigmoid(1.702 * gate) * (up + 1). MegaMoEV2 accepts act="swigluoai" (with a positive swiglu_limit) and applies it in both GEMM1 epilogues through one helper, gated_act_f32: the shared SiluQuantEpilogue (staged route) and the ring GEMM1 of the fused small-input kernel, which takes act and keys its kernel name on it. The test reference gains the activation, an "m31" network and an MX rounding emulation (_reference(quantize=(input, hidden))) for an error check against the op's own quantization. Co-Authored-By: Claude <[email protected]>
…route Adds the MiniMax-M3.1 EP4 layout (4 ranks, 128 experts, top-4, hidden 6144, inter 3072) to the fused small-input kernel, both quants, with its SwiGLU-OAI activation clamped at 7. FUSED_LAYOUTS now maps each layout to the one (act, swiglu_limit) it is built for, and fused_layout_supported checks that pair instead of SiLU at 10. M3.1 is in SMALL_M_ONLY_LAYOUTS: the large-input kernel's epilogue is SiLU only and it combines over FP8, so a call above the small-input capacity takes the staged route. The fixed-slot dispatch admits 4 ranks x 32 experts. _tune_m31_ep4_small starts from the EP4 DeepSeek-V4.1-Flash tune, sends BF16 combine rows at every row count (new FusedStage1Knobs.bf16_wire, the M3.1 numerics) and, at bucket 128 (the decode points), caches W1 and starts GEMM2 early. Tests: the routes suite takes --network m31 and checks a call one row above the small-input capacity; a CPU test pins the M3.1 layout gate and its BF16 wire; bench_mega_moe_m31.py times M3.1 decode points on captured routing. Co-Authored-By: Claude <[email protected]>
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_wire. 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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
|
Superseded by #8922: the same commit, reopened from a ROCm/aiter branch so the three PRs form a stack (stack #8923) and each shows only its own diff. |
Ready for review. No blocking issues. Stacked on #8917 and #8916; review only the last commit (
ef6599c43). A cross-repo PR cannot target a fork branch, so this branch carries their commits too.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.
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_wire(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: 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: routes suite--combine-wire bf16m31 a8w4 and a4w4 64 PASS each, V4.1-Flash EP4 58 PASS."auto"V4.1-Flash EP4 57 PASS. CPU route-plan tests 218 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.🤖 Generated with Claude Code