MI350 MLA PS mode fold nhead64,2 to nhead32,4 kernel#2570
Merged
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
2f178d2 to
4a15903
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the existing “q seqlen folding” support so additional (num_heads, q_len) combinations (notably 64×2 and 128×1) can be mapped onto the existing gfx950 FP8 (nhead=32, qlen=4) persistent MLA kernel path, aligning metadata generation and Python-side reshape logic accordingly.
Changes:
- Extend qseqlen-fold detection/selection to optionally fold to nhead=32 (instead of always nhead=16) when it yields qlen=4.
- Update device-side metadata generation (v1.2) to apply the new fold-to-32 behavior.
- Update the persistent MLA test’s reference path to track
use_qseqlen_foldand reshape outputs correctly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| op_tests/test_mla_persistent.py | Updates reference implementation reshape logic for the new qseqlen-fold behavior and propagates a use_qseqlen_fold flag. |
| csrc/kernels/mla/metadata/v1_2_device.cuh | Adds fold-to-32 handling in metadata generation for gfx950 FP8 cases. |
| aiter/ops/attention.py | Expands qseqlen-fold condition used for sizing/tiling metadata buffers. |
| aiter/mla.py | Updates persistent decode folding logic to choose between folding to nhead=16 vs nhead=32 depending on qlen folding outcome. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
valarLip
approved these changes
Apr 4, 2026
yzhou103
pushed a commit
that referenced
this pull request
Apr 8, 2026
* fold max_seqlen_q * (nheads // 32) == 4 to nhead32,4 kernel * fix nhead48,4 fold error * rollback nhead=128,1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
fold nhead64,2 to nhead32,4 kernel
Technical Details
Extend qseqlen-fold detection/selection to optionally fold to nhead=32 (instead of always nhead=16) when it yields qlen=4.
Update device-side metadata generation (v1.2) to apply the new fold-to-32 behavior.
Update the persistent MLA test’s reference path to track use_qseqlen_fold and reshape outputs correctly.
Test Plan
python3 op_tests/test_mla_persistent.py --nhead 64,2 -d fp8 -kvd fp8 -c 1024 8192 32768 -b 64
python3 op_tests/test_mla_persistent.py --nhead 16,4 32,2 64,1 32,4 128,1 64,2 -d fp8 -kvd fp8 -c 1024 8192 32768 -b 64
Test Result
perf对比:

Submission Checklist