Repository navigation
[ROCm][Perf][MiniMax-M3.1] Retune the MXFP8 dot_scaled GEMM tiles for M=17-256 - #65530
Conversation
… M=17-256 The gfx950 MXFP8 linear selected one narrow tile for every M up to 64 and a 64x64 tile above it, so the MiniMax-M3.1 TP4 linears (fused qkv, o_proj, shared-expert gate_up/down, dense gate_up/down, DSpark qkv) re-read their weights from several M tiles or ran under-occupied at decode and verify batch sizes. Add a shape-scoped tile table for M <= 256; M <= 16 for qkv, gate_up and shared down is unchanged, and other shapes and non-gfx950 are untouched. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
| _BK256_STAGES = 2 | ||
|
|
||
|
|
||
| # gfx950 tiles for the MiniMax-M3.1 TP4 MXFP8 linears, keyed by the local (N, K): |
There was a problem hiding this comment.
simpler comments
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
on_cdna() also covers gfx90a and gfx942; the tiles were tuned on gfx950 only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
|
Can you compare the results against this competing PR #62509? |
|
Update (70570c7): TP2 rows folded in. I added #62509's tiles for the TP2 shapes (fused qkv 4992x6144, dense gate_up 12288x6144, including its exclusion at TP2 qkv M=129-192, which keeps main's tile) and its dense down tile for M=65-128 to the table here, so this PR now covers everything the N-bucket path tunes for MiniMax-M3.1 and keeps the exact (N, K) tiles on top. The table and selector are renamed Setup. MI355X, one GPU, same harness for all arms: HIP-graph replay over about 400 MiB of rotating weights, median of 30 device-event samples x 5 rounds. Both PRs only change tile selection, so each arm uses its own Correctness. All 144 points are bit-identical to main (0 elements differ). Result. This PR is never more than 3% slower than main, #62509 or the previous table at any of the 144 points.
TP4, us per launch (main / #62509 / this PR):
Per decode step, TP4 (launches per step: qkv 60, o_proj 65, shared gate_up 57, shared down 57, dense gate_up 8, dense down 8, DSpark qkv 5), us per step:
So the two PRs are now equivalent where #62509 tunes (M=32-64 at TP4, all of TP2), and this PR is faster where it has the extra exact-shape tiles (1-2 requests, M=72-96, M >= 160), with no regression anywhere on the grid. What this does not cover. Kernel-level only: I did not run AgentX for #62509, and did not time the DeepSeek V4.1 shapes it also tunes (this table is keyed on the MiniMax-M3.1 local shapes, so V4.1 keeps main's selection). If you prefer a single owner for the mid-M tiles including V4.1, the remaining difference between the two PRs is that N-bucket path for other models. AI assistance: the runs were driven with Claude Code. 🤖 Generated with Claude Code |
|
Thanks, yeah it seems like taking the TP4 shapes in this one but the TP2 shapes from #62509 is the best way to go |
…ense-down M=65-128 tile Fold the TP2 fused qkv (4992x6144) and dense gate_up (12288x6144) rows and the dense down (6144x3072) M=65-128 tile, found faster than the old fallback in a head-to-head against vllm-project#62509, into the shape-keyed table. Rename it to _M31_TILES / _select_m31_cfg since it is no longer TP4 only. Co-authored-by: jiacao-amd <254980585+jiacao-amd@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
70570c7 to
f5d6d0a
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #100397 for commit |
|
/ci retry |
|
✅ Queued 1 failed job(s) for retry in Buildkite CI #100397. |
… M=17-256 (vllm-project#65530) Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: jiacao-amd <254980585+jiacao-amd@users.noreply.github.com> Co-authored-by: Micah Williamson <micah.williamson@amd.com>
What
RocmDotScaledMxfp8LinearKernel(Tritontl.dot_scaled) picks its tile in_select_cfg. For the MiniMax-M3.1 TP4 linears on gfx950, M=17-64 used a single narrow 16x16 tile and M=65-256 a 64x64 / 8-warp tile. This adds a shape-scoped tile table (_M31_TP4_TILES, keyed by the local(N, K)) for M <= 256 covering the fused qkv, o_proj, shared-expert gate_up / down, dense gate_up / down and the DSpark qkv. Decode and verify batches are M = 8 x requests, so M = 8..256 spans c1..c32.Everything else is unchanged: M <= 16 for qkv / gate_up / shared down keeps its tile, M > 256 and every other shape use the existing selection, every other arch is untouched (the tile table is gated on CDNA4,
get_cdna_version() == 4, i.e. gfx95x where it was tuned).Why
These GEMMs read each weight byte once and are weight-bandwidth bound (FLOPs are under 10% of the time at M=32, about 40% at M=128). What matters is how many M tiles re-read the same weights and how many programs fill the 256 CUs. A BLOCK_M that follows M, three pipeline stages for the shorter K tiles, and 4 warps for the 64x64 tiles remove most of the gap: for example fused qkv at M=64 goes from 4 M tiles of 16 to 2 tiles of 32.
Results
MI355X, one GPU, HIP-graph replay over rotating weights (400 MiB of weights so they come from HBM, as in the model); worst of two interleaved rounds. A warm-weights (8 copies) check agrees (not shown). "Floor" is max(bytes / 8 TB/s, FLOPs / 5 PF) with bytes = fp8 weight + e8m0 scales + activation + bf16 output.
The tile for every M in 8..256 (plus off-grid M such as 17, 33, 49, 65, 97, 129, 200) is at least as fast as the current one; sweep points that did not beat the current tile by 3% keep it (for example fused qkv M=33-48, shared gate_up M=65-80, dense down M=65-128).
Per decode step (launches per step: qkv 60, o_proj 65, shared gate_up 57, shared down 57, dense gate_up 8, dense down 8, DSpark qkv 5; 261 total):
Correctness
Only the launch configuration changes. For every shape and M above the output is bit-identical to the current kernel (0 elements differ) and the error against the dequantized reference is unchanged (relative error 1.7e-3, below the 0.5% bound used in
benchmarks/kernels/benchmark_mxfp8_tp4.py). The unit tests pin the new table on gfx950 and check that every tile's BLOCK_K divides K (the K loop is unmasked);tests/kernels/quantization/test_rocm_mxfp8_linear.pypasses (191 tests) on MI355X. The in-GEMM activation quant path (_select_fused_quant_cfg, M <= 16) is not touched.Relation to other work
This keeps the Triton kernel and its
QuantizedActivationinput, so the fused norm / swiglu / attention-epilogue quantization from #65478 and #65508 keeps applying, and it is independent of #65479 (AITER FlyDSL GEMM): it improves the kernel that remains the fallback for shapes AITER has no tuned rows for.The TP2 qkv and dense gate_up rows and the dense-down M=65-128 tile come from a head-to-head against #62509 by @jiacao-amd, whose tile results were folded into the shape-keyed table (credited as co-author on the commit).
🤖 Generated with Claude Code