Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
e6828e7 to
0b1c3c4
Compare
The shared expert (a native group-32 FP8 MLP beside the MXFP4 routed experts) quantizes the post-attention rows with `quantize_fp8` before its gate_up, while the routed MoE's A1 quant reads the same rows. With ATOM_MINIMAX_M3_MOE_QUANT_SHARED=1 the experts run through a new `moe_forward_mxfp8_copy` op that returns those rows as MXFP8 too: the MXFP4 method hands aiter's fused_moe `mxfp8_copy_out`, and the gfx1250 grouped A1 quant writes it in its own pass (aiter: bitwise `quantize_fp8`'s bytes). The shared expert then takes them as `x_scale` and skips its quant launch; it stays a separate MXFP8 MLP. The flag applies only where the shared gate_up is a native group-32 linear that quantizes its input (not its BF16 fallback) and the experts use the MXFP4 method. Paths where the experts do not take the local rows through aiter's fused_moe (Triton experts, the modular kernel, DP/PCP gathers, SP MegaMoE, simulated DP) fill the copy with `quantize_fp8` themselves. The op returns the E8M0 scale as uint8, viewed back by the caller: it mutates hidden_states, so torch.compile wraps it in auto_functionalized_v2, which Inductor does not decompose when it returns E8M0. Default off; needs aiter with ROCm/aiter#8364. Co-Authored-By: Claude Opus 5.5 <[email protected]>
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
…n the same pass A shared expert run beside the routed MXFP4 MoE (MiniMax-M3.1) quantizes the same bf16 rows to MXFP8 in its own launch. The routed A1 quant already reads each row and reduces every 32-block's amax, so it can write that copy too: fused_moe / flydsl_moe_fused_quant_preshuffle take `mxfp8_copy_out=(payload, scale)`, row-major (M, K) E4M3 + (M, K/32) E8M0, the bytes of per_1x32_mx_quant_hip(quant_dtype=fp8, scale_type=fp8_e8m0) (amax floored at kAmaxFloor, RoundUp exponent against 448, v_cvt_scalef32_pk8_fp8_bf16). The three quant builds the M3.1 grouped MoE dispatches take a `mxfp8_copy` build flag (`_mx8cp` builds with two more pointers): token-multidest (plain and K-split), the compact-scale quant, and the route-indexed quant (each source row's first route writes it, mapped or not). Any other A1 path, or a non-grouped MoE / FHMoE, fills the copy with the same HIP quant in its own launch (`mxfp8_row_copy`). Without the flag every build is unchanged: the kernel bodies moved into a @flyc.jit body inlined into either signature. fused_moe's plugin contract moves to version 3 (two more outputs a v2 provider would leave unwritten, so v2 is not superseded); tests/plugin_contracts.json records it. op_tests/test_moe_quant_shared_mxfp8.py: for every variant at 8..32768 tokens, the routed outputs are bitwise unchanged with the copy on, and the copy is bitwise the HIP quant, the separate launch and a torch model of the rule; the public fused_moe path keeps its output and launch count; the benchmark times the fused launch against the routed quant and the HIP quant. Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_clamp_shared_preserves_existing_positional_argument_order lists every fused_moe parameter from quant_type_a on. mxfp8_copy_out is appended after w2_global_scale, so the positional order of the existing arguments is unchanged; the test's list gains the new last name. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…s it aiter.moev2.api.op_call copies the arguments fused_moe passes to fused_moe_, and aiter.moev2.fused_moe keeps the legacy signature, so both take the MXFP8 copy output added here (tests/test_moev2_dispatch.py and tests/test_moev2_switch.py compare them with the legacy code). The a8w8_pt path writes no such copy: it lists the two arguments as unsupported, so a call that asks for the copy goes back to the legacy code. Co-Authored-By: Claude Fable 5.2 <[email protected]>
2739323 to
f78fe29
Compare
Conflicts: main added the post_gemm2_rms_* arguments to fused_moe and took contract version 3 for them. mxfp8_copy_out / mxfp8_copy_payload / mxfp8_copy_scale now follow them, and the fused_moe contract goes to version 4 (tests/plugin_contracts.json rewritten for it). Co-Authored-By: Claude Fable 5.2 <[email protected]>
The copy pointers are a tuple operand of each quant kernel (empty with the copy off, so those builds and their launchers are main's, untouched), and a copy build adds only its launcher. The wrapper decides once whether the routed quant can fold the copy and otherwise launches it on its own, in place of the scattered fallbacks and refusals of calls the fallback serves. Co-Authored-By: Claude Fable 5.2 <[email protected]>
One table of fused_moe calls, one per quant the grouped MoE can take plus one that cannot fold the copy: MoE output unchanged, copy equal to per_1x32_mx_quant_hip, and the kernel that wrote it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…t change python3 op_tests/test_moe_quant_shared_mxfp8.py now starts with the host argument check (any card), so with the six fused_moe cases, whose assertions and timings already come from one function, it covers what pytest collects. .github/scripts/aiter_test.sh is back to main's. Co-Authored-By: Claude Fable 5.2 <[email protected]>
- test: move the forced A-preshuffle case to 4096 tokens (off main's fused TP route, which fills no row_to_token), tell the kernel variants apart by name tag, make the refusal row wrong in shape only - one shared check: an fp16 hidden is allowed where the HIP quant writes the copy, a missing copy tensor is a ValueError, and the grouped path reuses it for prequantized inputs - drop the routeks builder's copy of the wrapper's fold predicate; _mxfp8_copy_dest is module-private - docs: the copy is the HIP quant's bytes for finite inputs; which calls fold it Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
review-pr scan (ROCm/aiter main, Card and scan log at 88c0407CardROCm/aiter PR #8364 — [FlyDSL] [CI] gfx1250 MoE A1 quant: emit the shared expert's MXFP8 input in the same passAdds an opt-in Review (advisory):
Scan log |
moev2 moved the unsupported-argument list to migration/local.py; the two copy arguments are refused there, classified in call_cache.PARAMS and defaulted for the fhmoe entry. Co-Authored-By: Claude Fable 5.2 <[email protected]>
What
MiniMax-M3.1 quantizes the same bf16 hidden rows twice in every MoE layer: MXFP4 for the routed experts and MXFP8 for the shared expert. With this PR the gfx1250 routed quant (
moe_fused_route_quant_scatter.py) can write the shared expert's MXFP8 input in the same pass, so the shared expert's own quant launch goes away. The shared expert itself is unchanged (still a separate MXFP8 MLP).fused_moe(..., mxfp8_copy_out=(q, s)):qis the E4M3 payload[M, K],sthe E8M0 scale[M, K/32].per_1x32_mx_quant_hip(fp8, e8m0)for finite inputs._mx8cpbuilds), when the quant sees every bf16 source row. Every other call (A-preshuffled shapes, EP, a non-grouped MoE) writes the copy with the HIP quant in its own launch, which also takes an fp16 input. A prequantized input raises.mxfp8_copy_out: kernel names, signatures and ISA are unchanged. The copy pointers are a tuple operand of each kernel, empty with the copy off; a copy build adds only its launcher.fused_moegoes to version 4 (main took 3 forpost_gemm2_rms_*; a v3 provider would leave the copy unwritten).aiter.moev2takes the two new arguments and falls back to the legacy code when the copy is requested.Benefit
One idle MI455X at this head,
python3 op_tests/test_moe_quant_shared_mxfp8.py(one run, M3.1 shape, wholefused_moecall, µs):Folded, the copy saves 1.9-2.6 µs a layer at 8-192 tokens and 4.6-10.4 µs at 4096-16384; in its own launch it saves nothing. One run, and the middle column is two separately timed calls added: the own-launch row, where both sides run the same kernels, differs by 1.5 µs, so the small-token saving is near the harness's resolution. The model has 57 such layers.
Testing
One idle MI455X (gfx1250), image
rocm/fw-bringup:gfx1250-minimax-m3-20261112, FlyDSL 0.5.3, at this head:python3 -m pytest -q -s op_tests/test_moe_quant_shared_mxfp8.py: 7 passed in 175 s (the sixfused_moecases and the host argument check).python3 -m pytest -q op_tests/test_fhmoe.py -k positional_argument_order: 1 passed.python3 op_tests/test_moe_quant_shared_mxfp8.py: exit 0, the table above.On the host at this head (CPU only, FlyDSL 0.5.3 compile-only for gfx1250):
aiter.aot.flydsl.dry_run,cmpof the final ISA against main abec8a5: 81 / 81 quant kernels of the default set identical, and 29 / 29 of the shapes below built without the copy._mx8cpbuilds (the M3.1 ones, top-k 1 / 3 / 5 / 8, an FP8 routed quant, K from 256 to 16384) compile and are byte-identical to 97f6c1e.fused_moecases of the test, dry-run throughfused_moeon fake tensors: the five folded cases compile the_mx8cpbuilds the GPU run names in its table; A-preshuffle at 4096 tokens compiles none.python -m pytest -q tests/test_plugin_contracts.py tests/test_plugin_selector_arity.py tests/test_moev2_dispatch.py tests/test_moev2_switch.py tests/test_moev2_hooks.py tests/test_moev2_imports.py tests/test_moev2_ranking.py tests/test_jit_signature.py tests/test_moe_dispatch_snapshot.py: 128 passed, 3 failed; main abec8a5 fails the same 3 on this host.python tests/moe_dispatch/snapshot.py --checkanddifferential.py --check: identical, 0 problems.python -m pytest -q op_tests/test_moe_quant_shared_mxfp8.py: 1 passed (host argument check), 6 skipped (gfx1250 only).python -m black --checkandruff check --no-cacheon the changed Python files: clean.Not covered
_mx8cpvariants: they JIT on first use, and withFLYDSL_RUNTIME_RUN_ONLY=1a call that requests the copy raises.fused_moeplugin contract goes v3 -> v4; no out-of-tree provider was checked against v4.op_tests/flydsl_tests/test_flydsl_grouped_gemm.pyin this image (see Unverified); copy off rests on the ISA comparison.Dependencies
None. #7543 and #7547 edit the same quant builders. This PR does not move or re-indent the kernel bodies: per builder it adds one factory argument, a name tag, one kernel parameter and one hook line, and appends the copy launcher after main's (main's launcher is untouched). A new A1 entry point must handle
mxfp8_copy_out(fold it, or callmxfp8_row_copy).Open question
Is
fused_moe(..., mxfp8_copy_out=)the right surface, or should the copy be requested through the MoE quant config?PR Self-Review
Reviewed revision
33f89eb
Behavior and intent
mxfp8_copy_out; every existing call runs the unchanged kernels.Validation and unverified scope
python3 -m pytest -q -s op_tests/test_moe_quant_shared_mxfp8.py7 passed;python3 -m pytest -q op_tests/test_fhmoe.py -k positional_argument_order1 passed;python3 op_tests/test_moe_quant_shared_mxfp8.pyexit 0.aiter.aot.flydsl.dry_run+cmpof the final ISA: copy off, 81 / 81 + 29 / 29 quant kernels identical to main abec8a5; 29 / 29_mx8cpbuilds identical to 97f6c1e.python tests/moe_dispatch/snapshot.py --checkanddifferential.py --checkclean; the moev2 / plugin / jit-signature tests 128 passed, 3 failed (the same 3 fail on main abec8a5 on this host);python -m pytest -q op_tests/test_moe_quant_shared_mxfp8.py1 passed, 6 skipped; black and ruff clean.aiter/moev2/migration/local.py, so the two copy arguments are refused there, classified incall_cache.PARAMSand defaulted for the fhmoe entry. The moev2 / plugin / jit-signature tests plustests/test_moev2_call_cache.py: 242 passed, 5 failed; main ed1163f fails the same 5 on this host.python3 -m pytest -q op_tests/flydsl_tests/test_flydsl_grouped_gemm.pygives no regression signal in this image: it aborts with a GPU memory fault intest_grouped_a4w4_situv2_kimi_k3_tp8_k_tail_matches_torch_ref(3 runs), and main abec8a5 aborts in the same test (2 runs), in kernels this PR does not touch. Also unverified: CI at this revision; the moev2 GPU checks; Inf / NaN inputs; top-k 5, an FP8 routed quant and an fp16 input with the copy; host cost per call with the copy off (not measured; the copy-off wrapper path gains oneis not Nonetest, an empty tuple and an empty unpack per launch); a model end to end.Changed op tests
op_tests/test_moe_quant_shared_mxfp8.py(new)fused_moe(..., mxfp8_copy_out=)on the M3.1 shape, one case per quant the grouped MoE can take (routeks K-split and full row, multidest K-split and TDM-staged, compact) and one that cannot fold the copy: MoE output bitwise unchanged, copy bitwise equal toper_1x32_mx_quant_hip, and the kernel that wrote it; one host argument check.mxfp8_copy_outdoes not exist).op_tests/test_fhmoe.pyfused_moeparameter list gainsmxfp8_copy_outat the end.