Skip to content

MI350 mla ps fp8 mode suppport nhead*qseqlen >=128 through kernel mla_a8w8_qh32_qseqlen4_gqaratio32_ps - #3380

Merged
shengnxu merged 11 commits into
mainfrom
mmd/dev/mla_ps_fp8_32mx4
Jun 2, 2026
Merged

shengnxu merged 11 commits into
mainfrom
mmd/dev/mla_ps_fp8_32mx4

Conversation

@minmengdie

@minmengdie minmengdie commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR extends the gfx950 (MI350) MLA persistent-scheduling (PS) fp8/fp8 dispatch to support additional GQA shapes where nhead=32,4 64,2 64,3 64,4 128,1 128,2 128,3 128,4 by routing them through the existing mla_a8w8_qh32_qseqlen4_gqaratio32_ps entry, and updates Python/C++ dispatch and test-side shape gating to match.

Technical Details

Add a gfx950 fp8/fp8 PS “GQA catch-all” dispatch condition (32,4 64,2 64,3 64,4 128,1 128,2 128,3 128,4) and route to the gqa=32, qseqlen=4 PS kernel entry while passing runtime gqa_ratio via s_MQA.
Align Python dispatch/metadata sizing and test reference gating with the new catch-all rules; remove older special-cased branches.
Update MLA device-metadata native-support rules and folding logic to reflect the new native shape set.

Test Plan

python3 op_tests/test_mla_persistent.py -d fp8 -kvd fp8 -n 16,1 16,2 16,3 16,4 32,1 32,2 32,3 32,4 48,1 48,2 48,3 48,4 64,1 64,2 64,3 64,4 80,1 80,2 80,3 80,4 96,1 96,2 96,3 96,4 112,1 112,2 112,3 112,4 128,1 128,2 128,3 128,4 -c 21 64 256 512 1200 3200 5200 8192 16384 -b 1 3 5 16 32 64 128

python3 op_tests/test_mla_persistent.py -d fp8 -kvd fp8 -n 64,2 64,3 64,4 128,1 128,2 128,3 128,4 -c 21 -b 1 3 5 64 -lse

Test Result

image image

Submission Checklist

@minmengdie
minmengdie requested review from a team and Copilot May 28, 2026 02:31
@github-actions

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:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
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 3380 --add-label <label>

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.

Pull request overview

This PR extends the gfx950 (MI350) MLA persistent-scheduling (PS) fp8/fp8 dispatch to support additional GQA shapes where nhead * qseqlen >= 128 by routing them through the existing mla_a8w8_qh32_qseqlen4_gqaratio32_ps entry, and updates Python/C++ dispatch and test-side shape gating to match.

Changes:

  • Add a gfx950 fp8/fp8 PS “GQA catch-all” dispatch condition (gqa_ratio * max_seqlen_q >= 128 || gqa_ratio > 64, excluding 48) and route to the gqa=32, qseqlen=4 PS kernel entry while passing runtime gqa_ratio via s_MQA.
  • Align Python dispatch/metadata sizing and test reference gating with the new catch-all rules; remove older special-cased branches.
  • Update MLA device-metadata native-support rules and folding logic to reflect the new native shape set.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
op_tests/test_mla_persistent.py Updates “natively supported” gating in the Torch reference path to mirror the new fp8/fp8 PS catch-all dispatch.
csrc/py_itfs_cu/asm_mla.cu Adds fp8/fp8 PS catch-all routing to the gqa=32, qseqlen=4 PS kernel entry and adjusts validation.
csrc/kernels/mla/metadata/v1_2_device.cuh Updates native-support detection and head/qlen folding rules for gfx950 fp8/fp8 PS catch-all shapes.
aiter/ops/attention.py Adjusts qseqlen-fold sizing heuristics and tile sizing for gfx950 shapes to match updated native support.
aiter/mla.py Replaces older fp8/fp8 PS special-cases with a unified gfx950 catch-all dispatch condition and simplifies folding logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread csrc/py_itfs_cu/asm_mla.cu Resolved
Comment thread aiter/mla.py Resolved
shengnxu
shengnxu previously approved these changes May 29, 2026
@minmengdie
minmengdie requested a review from shengnxu June 2, 2026 08:15
@shengnxu
shengnxu merged commit fbd6ce8 into main Jun 2, 2026
41 checks passed
@shengnxu
shengnxu deleted the mmd/dev/mla_ps_fp8_32mx4 branch June 2, 2026 08:16
amirumoAMD pushed a commit that referenced this pull request Jun 2, 2026
…_a8w8_qh32_qseqlen4_gqaratio32_ps (#3380)

* mla_a8w8_qh32_qseqlen4_gqaratio32_ps support gqa_ratio

Co-authored-by: Cursor <[email protected]>

* fix the kernel error

* fix the use_qseqlen_fold

* fix the err

* del the unuse code

* add return lse kernel

* only nhead=32 64 128 go through 32mx4

* fix the mi300 error

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Xin Huang <[email protected]>
Co-authored-by: Xu, Shengnan <[email protected]>
hubertlu-tw added a commit to hubertlu-tw/aiter that referenced this pull request Jul 9, 2026
Keep the ROCm#3380 folded kernel route but pass the qh32/qseqlen4 launcher stride expected by the kernel, and add a focused persistent MLA regression preset for the SGLang batch-stride failure.
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.

4 participants