Skip to content

[ROCm][Perf][MiniMax-M3.1] Retune the MXFP8 dot_scaled GEMM tiles for M=17-256 - #65530

Merged
shen-shanshan merged 6 commits into
vllm-project:mainfrom
Fangzhou-Ai:rocm-mxfp8-select-cfg-retune
Nov 6, 2026
Merged

shen-shanshan merged 6 commits into
vllm-project:mainfrom
Fangzhou-Ai:rocm-mxfp8-select-cfg-retune

Conversation

@Fangzhou-Ai

@Fangzhou-Ai Fangzhou-Ai commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

What

RocmDotScaledMxfp8LinearKernel (Triton tl.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.

layer (N x K) M current (us) this PR (us) speedup roofline floor (us) % of roofline
fused qkv (2560x6144) 8 6.3 6.3 1.00x 2.0 32%
fused qkv (2560x6144) 16 6.2 6.2 1.00x 2.0 33%
fused qkv (2560x6144) 32 10.1 7.5 1.34x 2.1 28%
fused qkv (2560x6144) 64 17.6 11.4 1.54x 2.1 19%
fused qkv (2560x6144) 128 20.1 13.8 1.45x 2.2 16%
fused qkv (2560x6144) 256 20.5 18.8 1.09x 2.4 13%
o_proj (6144x2048) 8 5.3 4.5 1.16x 1.6 36%
o_proj (6144x2048) 16 5.3 4.8 1.11x 1.6 35%
o_proj (6144x2048) 32 8.9 5.3 1.67x 1.7 32%
o_proj (6144x2048) 64 14.0 6.3 2.23x 1.7 28%
o_proj (6144x2048) 128 9.2 8.7 1.06x 1.9 21%
o_proj (6144x2048) 256 16.8 11.1 1.52x 2.1 19%
shared gate_up (1536x6144) 8 6.2 6.2 1.00x 1.2 20%
shared gate_up (1536x6144) 16 6.2 6.2 1.00x 1.2 20%
shared gate_up (1536x6144) 32 7.9 6.3 1.26x 1.2 20%
shared gate_up (1536x6144) 64 10.0 7.4 1.34x 1.3 17%
shared gate_up (1536x6144) 128 17.9 11.5 1.56x 1.4 12%
shared gate_up (1536x6144) 256 19.9 13.7 1.46x 1.5 11%
shared down (6144x768) 8 3.3 3.3 1.00x 0.6 19%
shared down (6144x768) 16 3.4 3.4 1.00x 0.6 19%
shared down (6144x768) 32 4.1 3.5 1.16x 0.7 19%
shared down (6144x768) 64 5.2 4.1 1.26x 0.7 17%
shared down (6144x768) 128 5.1 4.6 1.09x 0.8 18%
shared down (6144x768) 256 6.9 5.8 1.20x 1.0 18%
dense gate_up (6144x6144) 8 11.5 11.4 1.00x 4.9 43%
dense gate_up (6144x6144) 16 11.5 11.5 1.00x 4.9 43%
dense gate_up (6144x6144) 32 19.6 11.9 1.66x 4.9 42%
dense gate_up (6144x6144) 64 28.7 14.3 2.00x 5.0 35%
dense gate_up (6144x6144) 128 21.4 20.4 1.05x 5.2 25%
dense gate_up (6144x6144) 256 41.4 30.1 1.38x 5.5 18%
dense down (6144x3072) 8 6.9 6.2 1.11x 2.5 40%
dense down (6144x3072) 16 6.9 6.6 1.05x 2.5 38%
dense down (6144x3072) 32 11.9 6.9 1.72x 2.5 36%
dense down (6144x3072) 64 18.2 8.3 2.19x 2.6 31%
dense down (6144x3072) 128 12.0 12.0 1.00x 2.7 22%
dense down (6144x3072) 256 22.6 16.2 1.39x 2.9 18%
DSpark qkv (2304x6144) 8 7.9 6.3 1.26x 1.8 29%
DSpark qkv (2304x6144) 16 7.9 6.2 1.27x 1.9 30%
DSpark qkv (2304x6144) 32 9.9 7.5 1.32x 1.9 25%
DSpark qkv (2304x6144) 64 16.9 11.4 1.49x 1.9 17%
DSpark qkv (2304x6144) 128 20.1 13.7 1.46x 2.0 15%
DSpark qkv (2304x6144) 256 20.3 18.5 1.10x 2.2 12%

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):

requests M current (us/step) this PR (us/step) saving
2 16 1452 1407 45 us
4 32 2171 1544 628 us (29% of MXFP8 GEMM time, about 4.5% of a ~14 ms step)
8 64 3288 1990 1298 us
16 128 3477 2641 836 us

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.py passes (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 QuantizedActivation input, 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

… 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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added minimax rocm Related to AMD ROCm labels Nov 4, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Nov 4, 2026
_BK256_STAGES = 2


# gfx950 tiles for the MiniMax-M3.1 TP4 MXFP8 linears, keyed by the local (N, K):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

simpler comments

Fangzhou-Ai and others added 3 commits November 4, 2026 03:42
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>
@micah-wil

Copy link
Copy Markdown
Collaborator

Can you compare the results against this competing PR #62509?

@Fangzhou-Ai

Fangzhou-Ai commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

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 _M31_TILES / _select_m31_cfg, since the table is no longer TP4 only. This replaces my earlier numbers; the old table is called "before" below.

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 _select_cfg with one launcher and identical inputs; identical tiles are timed once. Arms: main (dd4e40142a), #62509 (753f28ea9d), this PR (70570c7255). Grid: the 7 TP4 shapes and the 2 TP2 shapes, M = 8, 16, 24, 32, 48, 56, 64, 72, 80, 88, 96, 112, 128, 160, 192, 256 (144 points).

Correctness. All 144 points are bit-identical to main (0 elements differ). tests/kernels/quantization/test_rocm_mxfp8_linear.py passes on MI355X (243 tests, now including the TP2 shapes in the dequant-reference test and the tile-selection / K-divisibility tests).

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):

layer M=16 M=64 M=96 M=192 M=256
qkv 2560x6144 6.3 / 6.3 / 6.3 17.6 / 11.4 / 11.4 20.0 / 13.8 / 11.8 20.4 / 18.5 / 14.1 20.5 / 18.8 / 18.8
o_proj 6144x2048 5.3 / 5.3 / 4.8 13.9 / 6.2 / 6.2 9.1 / 8.6 / 8.6 16.7 / 12.6 / 10.8 16.8 / 13.0 / 11.1
shared gate_up 1536x6144 6.2 / 6.2 / 6.2 10.0 / 7.5 / 7.5 16.2 / 11.3 / 11.3 20.2 / 13.6 / 13.6 20.0 / 13.8 / 13.8
shared down 6144x768 3.4 / 3.4 / 3.4 5.2 / 4.1 / 4.1 5.0 / 4.5 / 4.5 6.7 / 6.2 / 5.6 6.9 / 6.5 / 5.8
dense gate_up 6144x6144 11.5 / 11.5 / 11.5 28.6 / 14.4 / 14.4 21.4 / 20.3 / 20.3 41.2 / 36.0 / 29.0 41.4 / 36.8 / 30.2
dense down 6144x3072 6.9 / 6.9 / 6.6 18.3 / 8.3 / 8.3 11.9 / 11.5 / 11.5 22.3 / 18.8 / 15.8 22.7 / 19.7 / 16.3
DSpark qkv 2304x6144 7.9 / 7.9 / 6.2 16.7 / 11.3 / 11.3 19.9 / 13.6 / 11.7 20.4 / 18.4 / 14.0 20.3 / 18.5 / 18.5

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:

M main #62509 this PR
8 1449 1449 1388
16 1451 1451 1407
32 2171 1541 1541
64 3282 1985 1985
96 3363 2615 2485
128 3486 2640 2640
192 4452 3594 3078
256 4467 3675 3427

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

@micah-wil

Copy link
Copy Markdown
Collaborator

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>
@Fangzhou-Ai
Fangzhou-Ai force-pushed the rocm-mxfp8-select-cfg-retune branch from 70570c7 to f5d6d0a Compare November 5, 2026 22:04
@micah-wil micah-wil added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 6, 2026
@micah-wil

Copy link
Copy Markdown
Collaborator

/ci run

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #100397 for commit aa346e21bbab.

@Fangzhou-Ai

Copy link
Copy Markdown
Collaborator Author

/ci retry

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

✅ Queued 1 failed job(s) for retry in Buildkite CI #100397.

@shen-shanshan
shen-shanshan merged commit 405aaa3 into vllm-project:main Nov 6, 2026
104 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Nov 6, 2026
yeshihai pushed a commit to yeshihai/vllm that referenced this pull request Nov 8, 2026
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minimax ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants