Skip to content

[Triton/Gluon] moe_gemm_a8w8: fnuz FP8 and MXFP8 on gfx942 - #6219

Merged
azaidy merged 3 commits into
ROCm:mainfrom
akii96:aakif/a8w8-moe-fnuz-mxfp8-gfx942
Oct 30, 2026
Merged

azaidy merged 3 commits into
ROCm:mainfrom
akii96:aakif/a8w8-moe-fnuz-mxfp8-gfx942

Conversation

@akii96

@akii96 akii96 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

moe_gemm_a8w8 does not run on gfx942. The arch uses the fnuz FP8 encoding, which tl.dot_scaled rejects, so float8_e4m3fnuz inputs fail to compile. MXFP8 MoE models on MI300X therefore fall back to dequantizing expert weights to BF16 at load. For Hy4-preview-FP8 at TP8 that needs about 186 GiB per GPU and runs out of memory.

Replaces #5831. Per review, this extends moe_gemm_a8w8 instead of moe_gemm_mxfp8.py, which #6035 removes.

Changes

  • USE_FNUZ follows the input dtype.
  • Plain FP8 on gfx942 runs tl.dot on the FP8 operands. Scales stay in the fp32 epilogue.
  • MXFP8 on gfx942 runs one FP8 dot per 32-wide K slice and applies its E8M0 scales to the fp32 result. This keeps the FP8 MFMA path from [Triton/Gluon] [Perf] MXFP8 MoE: keep the MFMA in FP8 when MX_SCALE_BLOCK_K == 1 #5832 for BLOCK_K 32, 64 and 128, instead of upcasting the operands to fp32.
  • MXFP8 shapes read a tuned table through the same dispatch as a8w4 and a16w4 (bm<block_m>_n_k), with NUM_KSPLIT for long K. The gfx942 table uses BLOCK_K=128. Shapes without an entry use the widest BLOCK_K that divides K, and short K stays at 32. Plain FP8 keeps the existing heuristic.
  • dynamic_mxfp8_quant scales fnuz to its own range (max 240) instead of the OCP 448. It also uses an int64 row offset, since stacked expert weights can pass 2**31 elements.
  • Split-K fixes in the wrapper:
    • Partials are kept in fp32 before the reduction.
    • swiglu with gammas falls back to split_k=1, because gammas were applied to each partial before the swiglu.
    • split_k is halved until each slice holds whole K tiles.

Test

test_op_gfx942 in the existing test_moe_gemm_a8w8.py, 5 cases: plain FP8, MXFP8 decode, MXFP8 w2, MXFP8 prefill, and one ragged MXFP8 shape that misses the tuned table. test_per_1x32_mxfp8_quant_fnuz in test_quant_mxfp8.py checks the fnuz quant range against the original bf16 input. It fails if the range goes back to 448. About 8 s on MI300X, skipped on other archs.

Results

Hy4-preview-FP8 TP8 through vLLM, Triton 3.8.0. These results are from d771de7, before the split-K fixes which should only make the numbers better

Memory

Model TP MXFP8 (this PR) BF16 dequant
Hy4-preview-FP8 8 99.25 GiB per GPU 185.87 GiB, out of memory on MI300X
MiniMax-M3-MXFP8 4 107.8 GiB per GPU 201.9 GiB
MiniMax-M3-MXFP8 2 211.7 GiB per GPU does not fit

Performance

MI300X, dummy weights, 1024 in / 256 out:

Concurrency TPOT TTFT Output tok/s
1 22.7 ms 256 ms 42.3
8 24.3 ms 785 ms 293.4
32 30.5 ms 1696 ms 863.8

Accuracy

GSM8K, MI325X, real weights, all 1,319 samples, 5-shot chat, temperature 0.9, top-p 1.0, seed 0, 32K output limit:

Scoring Accuracy Extractable Truncations
lm-eval flexible-extract, stock stop strings 36.32% ± 1.32 486/1319 0
flexible-extract, no stop strings 96.97% ± 0.47 1319/1319 0

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6219 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Configuration duplication, Python-side tuning, and uncovered fnuz dispatch variants should be addressed.

4 open findings
What changed in this PR

Adds gfx942 fnuz FP8/MXFP8 support to the Triton MoE A8W8 kernel.

Changes:

  • Adds fnuz-aware dot and quantization scaling paths.
  • Introduces gfx942 MXFP8 dispatch tuning.
  • Adds gfx942 correctness and quantization tests.
File Description
aiter/​ops/​triton/​moe/​moe_op_gemm_a8w8.py Adds fnuz dispatch and configuration selection.
aiter/​ops/​triton/​_triton_kernels/​moe/​moe_op_gemm_a8w8.py Implements fnuz FP8 dot paths.
aiter/​ops/​triton/​quant/​quant.py Selects the fnuz quantization range.
aiter/​ops/​triton/​_triton_kernels/​quant/​quant.py Parameterizes MXFP8 scale derivation.
aiter/​ops/​triton/​configs/​gfx942/​triton/​moe/​a8w8/​DEFAULT.json Adds gfx942 tuned configurations.
op_tests/​triton_tests/​moe/​test_moe_gemm_a8w8.py Adds gfx942 correctness coverage.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@akii96

akii96 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@lburzawa @nsusanto @Boss2002n the last push goes beyond just the test fix:

  • Review item: gfx942 cases are now rows in test_op.
  • Split-K fixes: the wider tests caught a split-K + swiglu accuracy bug. Partials now stay in fp32, swiglu with gammas uses split_k=1, and split_k is halved until each slice holds whole K tiles.
  • BLOCK_K up to 128: gfx942 MXFP8 runs one FP8 dot per 32-wide K slice instead of upcasting to fp32. The table is retuned at BLOCK_K=128.
  • Quant fix: dynamic_mxfp8_quant uses an int64 row offset. It faulted past 2**31 elements.

Per-GEMM speedup over the BLOCK_K=32 table (MI300X, 256 experts, top-8):

Shape Decode (bm16) Prefill (bm128)
N=512, K=6144 2.7x 1.4x
N=768, K=6144 2.7x 1.5x
N=6144, K=256 2.7-3.5x 1.0x
N=6144, K=384 2.0-2.6x 1.1x

bm32 and bm64 entries gain 1.1-3.2x. Short-K prefill needs kernel work, which I'll do in a follow-up PR later

Tested on MI300X: a8w8 160 passed, mxfp8 quant 104 passed

@lburzawa

Copy link
Copy Markdown
Contributor

Can you post performance comparison of the split-k approach on BLOCK_K=64 and BLOCK_K=128 as compared to existing approach which upcasts the operands to fp32 before the tl.dot?

@akii96

akii96 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@lburzawa here is the comparison with the fp32 upcast on main.

Setup: MI325X, MXFP8 activations and weights, 256 experts, top-8. Same wrapper, config and inputs on both sides. Only the kernel differs. Time is the full moe_gemm_a8w8 call.

  • BLOCK_K=64: 1.39x to 3.84x faster, geomean 2.35x
  • BLOCK_K=128: 2.45x to 6.67x faster, geomean 3.90x
  • Against the upcast at its best BLOCK_K per shape: 2.07x faster
  • BLOCK_K=32: both within 2%, as expected, since both run one FP8 dot there
  • Outputs match in every case

The upcast runs fp32 MFMA and spills registers at BLOCK_K=128. This PR stays on FP8 MFMA with no spills.

All 28 cases (µs)
N K tokens block_m main 32 PR 32 main 64 PR 64 64 speedup main 128 PR 128 128 speedup
512 6144 16 16 299.4 298.6 316.8 187.5 1.69x 283.8 116.0 2.45x
512 6144 1024 32 1,374.1 1,350.2 1,126.2 678.1 1.66x 1,233.6 366.0 3.37x
512 6144 2048 64 1,258.1 1,257.3 2,409.1 932.9 2.58x 2,520.9 729.6 3.46x
512 6144 8192 128 2,545.9 2,551.0 5,694.4 1,621.6 3.51x 7,558.4 1,190.2 6.35x
768 6144 16 16 413.2 409.4 312.9 224.4 1.39x 330.3 129.1 2.56x
768 6144 1024 32 2,076.8 2,074.9 1,700.9 1,037.9 1.64x 1,868.4 517.7 3.61x
768 6144 2048 64 1,563.8 1,562.6 2,502.7 980.9 2.55x 4,023.8 684.0 5.88x
768 6144 8192 128 3,676.4 3,665.0 8,051.6 2,266.6 3.55x 10,913.5 1,724.5 6.33x
1536 6144 16 16 1,186.7 1,185.1 1,158.9 686.0 1.69x 1,810.2 356.6 5.08x
1536 6144 1024 32 3,698.4 3,697.8 4,256.7 1,985.0 2.14x 4,254.6 1,497.9 2.84x
1536 6144 2048 64 3,278.6 3,272.1 5,414.4 2,111.3 2.56x 8,546.0 1,281.1 6.67x
1536 6144 8192 128 7,852.4 7,850.9 19,396.8 5,051.1 3.84x 21,546.6 4,156.3 5.18x
3072 6144 16 16 1,754.2 1,756.8 1,333.0 859.1 1.55x 1,744.5 517.7 3.37x
3072 6144 1024 32 7,117.8 7,030.9 7,972.3 3,816.0 2.09x 7,977.3 2,832.9 2.82x
3072 6144 2048 64 6,514.0 6,518.9 10,716.6 4,231.4 2.53x 16,583.8 2,541.5 6.53x
3072 6144 8192 128 15,847.1 15,831.7 39,545.0 10,406.2 3.80x 43,932.8 8,580.8 5.12x
6144 256 16 16 117.5 116.2 115.6 70.0 1.65x 129.2 51.0 2.53x
6144 256 1024 32 495.3 495.5 565.7 289.6 1.95x 641.7 192.9 3.33x
6144 256 2048 64 358.1 358.9 1,175.7 512.7 2.29x 1,251.9 487.5 2.57x
6144 256 8192 128 1,060.2 1,061.7 2,770.7 901.5 3.07x 3,847.0 838.1 4.59x
6144 384 16 16 179.8 176.2 171.1 99.8 1.71x 196.6 66.6 2.95x
6144 384 1024 32 616.2 614.7 815.7 393.9 2.07x 878.5 246.8 3.56x
6144 384 2048 64 411.2 413.3 1,229.2 380.6 3.23x 1,597.0 374.9 4.26x
6144 384 8192 128 1,384.1 1,383.9 4,073.7 1,107.7 3.68x 5,496.1 1,082.0 5.08x
6144 1536 16 16 836.5 836.8 723.9 448.3 1.61x 899.4 273.6 3.29x
6144 1536 1024 32 3,266.1 3,266.8 4,031.1 1,776.1 2.27x 4,107.2 1,460.4 2.81x
6144 1536 2048 64 2,098.7 2,103.8 6,153.6 1,855.3 3.32x 6,798.3 1,861.3 3.65x
6144 1536 8192 128 7,526.0 7,530.1 19,503.2 5,270.1 3.70x 21,882.4 4,518.5 4.84x

@akii96

akii96 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Updates since the last review:

  • cc8bef8: shapes without a tuned entry now use the widest BLOCK_K that divides K instead of a fixed 32. Also added 12 missing table entries for Hy4-preview-FP8 TP8 and MiniMax-M3 TP2/TP4.
  • faf16e4: K=448 test case for the BLOCK_K=64 path.
  • Merged main.

On the target models (MI325X), 13 of 32 keys change. They are 1.23x to 3.54x faster, geomean 2.19x. The other 19 stay within 1%, and outputs are identical before and after.

The 13 keys that change (µs)
Model Key Tokens Before After Speedup BLOCK_K
Hy4 TP8 bm64_n512_k6144 2048 1,082.5 466.6 2.32x 32 to 128
Hy4 TP8 bm64_n6144_k256 2048 360.0 292.8 1.23x 32 to 128
MiniMax TP4 bm32_n1536_k6144 1024 1,886.6 532.9 3.54x 32 to 128
MiniMax TP4 bm128_n1536_k6144 4096 2,468.4 1,084.4 2.28x 32 to 128
MiniMax TP4 bm16_n6144_k768 16 151.4 68.8 2.20x 32 to 128
MiniMax TP4 bm32_n6144_k768 1024 602.3 222.6 2.71x 32 to 128
MiniMax TP4 bm64_n6144_k768 2048 437.6 345.3 1.27x 32 to 128
MiniMax TP4 bm128_n6144_k768 4096 926.3 553.4 1.67x 32 to 128
MiniMax TP2 bm32_n3072_k6144 1024 3,755.5 1,060.6 3.54x 32 to 128
MiniMax TP2 bm128_n3072_k6144 4096 4,975.2 2,118.7 2.35x 32 to 128
MiniMax TP2 bm32_n6144_k1536 1024 1,678.8 496.5 3.38x 32 to 128
MiniMax TP2 bm64_n6144_k1536 2048 1,058.4 629.1 1.68x 32 to 128
MiniMax TP2 bm128_n6144_k1536 4096 1,911.4 1,010.4 1.89x 32 to 128

Tests on MI325X: 176 passed in test_moe_gemm_a8w8.py and 104 passed in test_quant_mxfp8.py.

@azaidy
azaidy requested review from lburzawa and a balanced review from Copilot October 23, 2026 16:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fallback tile lookup fails for supported partial-K inputs, and the fnuz quantization range still lacks an independent regression check.

6 open issues
2 resolved since last review

Review effort: Balanced

Comment thread aiter/ops/triton/quant/quant.py Resolved
@lburzawa

Copy link
Copy Markdown
Contributor

@akii96 Thanks for the comparison. I requested one more change and please review new copilot comments. Otherwise we should be good to go.

@akii96
akii96 requested a review from lburzawa October 26, 2026 12:29
Enable gfx942 FP8 and MXFP8 paths in moe_gemm_a8w8, add tuned gfx942 configurations, preserve split-K correctness, and quantize FNUZ payloads against their native range.

Add gfx942 MoE coverage and integrate the representative FNUZ quant case into the existing MXFP8 parameterized test without increasing its workload.

Signed-off-by: Aakif Nawaz <[email protected]>
@akii96
akii96 force-pushed the aakif/a8w8-moe-fnuz-mxfp8-gfx942 branch from d6d8cea to b764e89 Compare October 27, 2026 22:55
@akii96

akii96 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@Boss2002n @lburzawa The MI35X Shard 5 failures (8× test_batched_gemm_afp4_wfp4[*-2-256-3584-2112]) don't look related to this PR. This PR doesn't touch the batched FP4 GEMM

It looks like the OOB e8m0 scale read on the ragged-K path that #7047 fixes

I would like to land this soon now as this brings huge perf benefit on recently released Minimax-3,1 so happy to take more feedback on this PR and test hardening while we wait for the other PR to merge and then lets land this soon after!

@lburzawa
lburzawa self-requested a review October 30, 2026 00:35

@lburzawa lburzawa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for taking into account all feedback.

@azaidy azaidy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@azaidy
azaidy merged commit 46c21ff into ROCm:main Oct 30, 2026
86 of 90 checks passed
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
* [Triton/Gluon] support fnuz FP8 and MXFP8 MoE on gfx942

Enable gfx942 FP8 and MXFP8 paths in moe_gemm_a8w8, add tuned gfx942 configurations, preserve split-K correctness, and quantize FNUZ payloads against their native range.

Add gfx942 MoE coverage and integrate the representative FNUZ quant case into the existing MXFP8 parameterized test without increasing its workload.

Signed-off-by: Aakif Nawaz <[email protected]>

* [Triton] test native MXFP8 dtype on each arch

Signed-off-by: Aakif Nawaz <[email protected]>

---------

Signed-off-by: Aakif Nawaz <[email protected]>
akii96 added a commit to akii96/vllm that referenced this pull request Nov 6, 2026
Adds the AITER_MXFP8_A8W8 backend for ModelOpt MXFP8 MoE on MI300 and MI325
(gfx942), selected ahead of EMULATION or explicitly with
--moe-backend aiter_a8w8. EMULATION dequantizes every expert weight to BF16
at load, roughly doubling MoE weight memory; with this backend the weights
stay MXFP8 (Hy4-preview-FP8, TP8: 185.87 -> 99.27 GiB per rank), which is
what lets Hy4-preview-FP8 TP8 fit on 192 GB MI300X.

- At load, OCP e4m3fn weights are reinterpreted as fnuz in place (E8M0
  exponent + 1, 0x80 -> 0), keeping one byte per element, and the E8M0
  scales are stored N-contiguous so per-K-step scale loads coalesce
  (gate/up GEMM 10-19% faster).
- Monolithic experts: router logits go through AITER's fused top-k and
  sort, then two moe_gemm_a8w8 calls with MXFP8 activations and vLLM's
  activation op in between. The path is CUDA-graph capturable.

Requires ROCm/aiter#6219 (gfx942 fnuz support in moe_gemm_a8w8).

Co-authored-by: Claude
Signed-off-by: Aakif Nawaz <[email protected]>
akii96 added a commit to akii96/vllm that referenced this pull request Nov 13, 2026
Adds the AITER_MXFP8_A8W8 backend for MXFP8 MoE on MI300 and MI325
(gfx942), selected ahead of EMULATION or explicitly with
--moe-backend aiter_mxfp8_a8w8. EMULATION dequantizes every expert weight
to BF16 at load, roughly doubling MoE weight memory; with this backend the
weights stay MXFP8 (Hy4-preview-FP8, TP8: 195.8 -> 109.1 GiB per rank),
which is what lets Hy4-preview-FP8 TP8 fit on 192 GB MI300X.

- gfx942 has no MX matrix cores, so moe_gemm_a8w8 runs each 32-wide K
  step as an FP8 MFMA and applies the E8M0 scales to the accumulator.
- At load, e4m3fn weights are reinterpreted as e4m3fnuz in place
  (mxfp8_e4m3fn_to_e4m3fnuz: E8M0 exponent + 1, 0x80 -> 0, exponents
  that cannot be bumped become NaN), and the scales are stored
  N-contiguous so per-K-step scale loads coalesce.
- Monolithic experts: router logits go through AITER's top-k and sort,
  then two moe_gemm_a8w8 calls with vLLM's activation in between.
  Supports Renormalize, RenormalizeNaive, MiniMax2 and DeepSeekV3 routing,
  routed-experts capture, and CUDA graphs. Rejects EP/DP, expert bias and
  fused shared experts.
- Opt out with VLLM_ROCM_USE_AITER_MOE=0, like the other AITER MoE paths.
- INCMxfp8MoEMethod gets apply_monolithic, since auto-selection can now
  return a monolithic kernel for it on gfx942.

Needs ROCm/aiter#6219, which is in the pinned AITER v0.1.28.post1.

Signed-off-by: Aakif Nawaz <[email protected]>
akii96 added a commit to akii96/vllm that referenced this pull request Nov 16, 2026
Adds the AITER_MXFP8_A8W8 backend for MXFP8 MoE on MI300 and MI325
(gfx942), selected ahead of EMULATION or explicitly with
--moe-backend aiter_mxfp8_a8w8. EMULATION dequantizes every expert weight
to BF16 at load, roughly doubling MoE weight memory; with this backend the
weights stay MXFP8 (Hy4-preview-FP8, TP8: 195.8 -> 109.1 GiB per rank),
which is what lets Hy4-preview-FP8 TP8 fit on 192 GB MI300X.

- gfx942 has no MX matrix cores, so moe_gemm_a8w8 runs each 32-wide K
  step as an FP8 MFMA and applies the E8M0 scales to the accumulator.
- At load, e4m3fn weights are reinterpreted as e4m3fnuz in place
  (mxfp8_e4m3fn_to_e4m3fnuz: E8M0 exponent + 1, 0x80 -> 0, exponents
  that cannot be bumped become NaN), and the scales are stored
  N-contiguous so per-K-step scale loads coalesce.
- Monolithic experts: router logits go through AITER's top-k and sort,
  then two moe_gemm_a8w8 calls with vLLM's activation in between.
  Supports Renormalize, RenormalizeNaive, MiniMax2 and DeepSeekV3 routing,
  routed-experts capture, and CUDA graphs. Rejects EP/DP, expert bias and
  fused shared experts.
- Opt out with VLLM_ROCM_USE_AITER_MOE=0, like the other AITER MoE paths.
- INCMxfp8MoEMethod gets apply_monolithic, since auto-selection can now
  return a monolithic kernel for it on gfx942.

Needs ROCm/aiter#6219, which is in the pinned AITER v0.1.28.post1.

Signed-off-by: Aakif Nawaz <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
* [Triton/Gluon] support fnuz FP8 and MXFP8 MoE on gfx942

Enable gfx942 FP8 and MXFP8 paths in moe_gemm_a8w8, add tuned gfx942 configurations, preserve split-K correctness, and quantize FNUZ payloads against their native range.

Add gfx942 MoE coverage and integrate the representative FNUZ quant case into the existing MXFP8 parameterized test without increasing its workload.

Signed-off-by: Aakif Nawaz <[email protected]>

* [Triton] test native MXFP8 dtype on each arch

Signed-off-by: Aakif Nawaz <[email protected]>

---------

Signed-off-by: Aakif Nawaz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants