Repository navigation
[Perf] [AMD] qsa: Faster decode MQA logits on ROCm (padded Q, group-strided launch) - #48649
Open
amd-cgilli wants to merge 1 commit into
Open
amd-cgilli wants to merge 1 commit into
amd-cgilli wants to merge 1 commit into
Conversation
amd-cgilli
added a commit
to amd-cgilli/sglang
that referenced
this pull request
Nov 5, 2026
… (11 + 16); PR links with state badges in the tables
…trided launch) On ROCm, pad the decode index Q to the MFMA width (16 heads) in the indexer prep and run the decode MQA-logits kernel with 256 threads; launch it group-strided: each CTA scores 4 consecutive key groups and the grid spans the page table, so long or mixed-length contexts no longer serialize inside a fixed number of CTAs per row (sgl-project#43463). CUDA path unchanged.
5 of 11 tasks
amd-cgilli
force-pushed
the
perf/amd-qsa-decode-mqa-launch
branch
from
November 5, 2026 15:51
182172f to
630a5aa
Compare
amd-cgilli
marked this pull request as ready for review
November 5, 2026 16:22
amd-cgilli
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
November 5, 2026 16:22
This branch has not been deployed
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
#43463 launches the QSA indexer's decode MQA-logits TileLang kernel with a fixed number of CTAs per row, each striding over the row's 64-key groups. On MI355X with long or mixed-length contexts (agentic serving of Qwen3.8-Flash-Next), this leaves long serial walks per CTA: in a mixed batch the kernel took 243 us/call vs 89 us with the launch below, x13 calls per decode step (~+2 ms per step).
Modifications
ROCm only; the CUDA path is unchanged.
qsa_indexer.py/mqa.py: pad the decode index Q to the MFMA width (16 heads) in the indexer prep, so the decode wrapper no longer re-pads; 256 threads for the decode kernel.mqa.py: new kernel arggroups_per_cta(0 = current behaviour). On ROCm each CTA scores 4 consecutive groups and the grid spans the page table (ceil(ceil(max_pages / sub_pages) / 4)); CTAs past a row's context exit at once.Accuracy Tests
Bit-exact: identical logits and top-k vs the current kernel (25 shapes, rows 16-192, context 20k-200k). Padded heads are zero, so they add 0 after the ReLU. GSM8K (1319, real MTP verification) on our full MI355X stack including this change: 96.80%.
CUDA: the traced TileLang kernel is identical to the current one (72/72 decode configs).
python -m pytest -v -rA test/registered/kernels/ops/attention/qsa/test_qsa_indexer.py test/registered/kernels/ops/attention/qsa/test_qsa_rocm.py -k "mqa or decode or rocm"
Note: the failure in
test_decode_selection_equivalentcalls the torch reference implementationtorch_qsa_mqa_decodeand not the TileLang kernel this PR changes.Speed Tests and Profiling
MI355X, decode MQA logits per call (rows x context): 96 x 87k 113.4 -> 78.3 us, 192 x 200k 591.5 -> 353.4 us, 1.2-1.7x at >= 50k; 16 x 20k 5.9 -> 8.4 us is the one slower shape.
End to end, Qwen3.8-Flash-Next AgentX agentic C24 (3600 s, TP1, MTP acceptance pinned 2.32): this change is worth roughly 7 p90 tok/s/user.
Related: #48251 (64 CTAs per row, NVIDIA-tuned), #48250 (NVIDIA JIT CUDA decode scorer), #46631 (shared compressed-key reads for verify rows).
Checklist
CI States
Latest PR Test (Base): ❌ Run #42059180871
Latest PR Test (Extra): ❌ Run #42059180584
Latest PR Test (AMD ROCm 10): ❌ Run #42059180671
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: