Skip to content

[Kernel][DSv4.1] Add batched MXFP8 GEMM with fused MXFP8 output on MI355X - #7

Merged
benenzhu merged 2 commits into
Inferact:mainfrom
shen-shanshan:dsv41-flash-woa-quant-fuse
Nov 20, 2026
Merged

benenzhu merged 2 commits into
Inferact:mainfrom
shen-shanshan:dsv41-flash-woa-quant-fuse

Conversation

@shen-shanshan

Copy link
Copy Markdown
Collaborator

Overview

On MI355X, vLLM runs DeepSeek-V4.1's grouped wo_a (8 groups of 1024 x 4096 at attention TP1, 32x32 E8M0 weight blocks) on AITER's batched_gemm_a8w8_mxscale_bpreshuffle. That GEMM writes bf16, and wo_b then quantizes the bf16 output to MXFP8 in a separate launch.

This PR adds gemm/mxfp8_bmm_mxfp8_out_n1024_k4096. Its entry mxfp8_bmm_mxfp8_out returns wo_b's MXFP8 input directly, as row-major e4m3 codes and E8M0 scales, in one launch.

  • Kernel. The main loop is AITER's gfx950 FlyDSL batched GEMM: one split, scaled 16x16x128 MFMAs in ascending K. The bf16 store is replaced by an MXFP8 quant of the LDS-staged bf16 tile.
  • Quant epilogue. Four lanes share a 32-column group and combine their amax with quad DPP. The E8M0 byte is computed in integers, and the codes come from v_cvt_scalef32_pk_fp8_f32.
  • Host. Tiles follow AITER's tuned FlyDSL rows for this shape. The entry warms every config up on its first call.

Numerics

  • Codes and scales equal AITER's FlyDSL batched GEMM followed by vLLM's Triton MXFP8 quantizer, bit for bit.
  • They also equal AITER's tuned dispatch, except on fp32-subnormal outputs, which AITER's OPUS kernels flush to zero.

Results

Kernel (one MI355X, graph replay, 8 groups, µs per call)

The baseline is AITER batched_gemm_a8w8_mxscale_bpreshuffle + vLLM _mxfp8_e4m3_quantize_triton.

M Baseline mxfp8_bmm_mxfp8_out Delta
1 8.35 6.56 −21.4%
128 14.19 12.04 −15.2%
1024 40.39 35.45 −12.2%
4096 144.35 126.37 −12.5%
8192 297.75 246.77 −17.1%
16384 541.91 489.18 −9.7%

vLLM end to end (DeepSeek-V4.1-Flash, 2x MI355X, DEP2, vllm bench forward, ms per step)

Case Baseline With this kernel Delta
prefill, 16384 tokens 395.90 392.92 −2.98 (−0.75%)
prefill, 8192 tokens 214.21 213.35 −0.87 (−0.41%)
decode, 16 requests x 6 tokens 38.42 38.26 −0.16 (−0.41%)
  • Setup: AITER MegaMoE + MoRI, fp8_e4m3 KV cache, DSpark with 5 draft tokens.
  • Layer-level check on real checkpoint weights (layers 0, 3, 20 and 39, M from 1 to 16384): the MXFP8 output and wo_b's output are bit-exact against the current vLLM path.
  • GSM8K (8-shot, all 1319 questions): strict-match 0.9227, flexible-extract 0.9212. This is within run-to-run noise of earlier runs (0.926–0.936).

Tests

python3 -m pytest tests/gemm/mxfp8_bmm_mxfp8_out_n1024_k4096 -q   # 72 passed
python3 benchmarks/gemm/mxfp8_bmm_mxfp8_out_n1024_k4096/benchmark_mxfp8_bmm_mxfp8_out.py

The tests cover:

  • 37 row counts (1 to 16384) and all 26 tile configs, each at a partial last M tile;
  • 8, 4, 2 and 1 groups;
  • the row counts where AITER's tuned dispatch picks OPUS;
  • CUDA graph replay and determinism;
  • the first-call warm-up, after which no row count compiles again.

🤖 Generated with Claude Code

DeepSeek-V4.1's grouped wo_a (B x 1024 x 4096, 32x32 E8M0 weight blocks) writes bf16 that only wo_b reads, and
wo_b quantizes it to MXFP8 in a separate launch. mxfp8_bmm_mxfp8_out does both in one launch: AITER's gfx950
FlyDSL batched GEMM main loop (single split, scaled 16x16x128 MFMAs in ascending K), with the bf16 store replaced
by an MXFP8 quant of the LDS-staged bf16 tile (quad DPP amax, integer E8M0 byte, v_cvt_scalef32_pk_fp8_f32).

Codes and scales equal AITER's FlyDSL batched GEMM + the Triton MXFP8 quantizer bit for bit, and AITER's tuned
dispatch except on fp32-subnormal outputs, which its OPUS kernels flush. Tiles follow AITER's tuned FlyDSL rows;
the entry warms every config up on its first call. Graph replay on one MI355X, 8 groups: -1.8 us at M 1 to
-52.7 us at M 16384 against the AITER GEMM + vLLM quantizer pair.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: shen-shanshan <[email protected]>
@benenzhu

Copy link
Copy Markdown
Member

wait for #5, mx gemm host.py need some change for upstream to vLLM

Conflict in amd_kernels/README.md only: main's index (Inferact#5's TP2 packages, Inferact#9's shape folders) with this PR's
gemm/mxfp8_bmm_mxfp8_out_n1024_k4096 line after the dense MLP gate_up lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Taoyu Zhu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants