Repository navigation
[AMD] Pad QSA MQA decode Q-heads to 16 for ROCm MFMA - #38875
Merged
HaiShaw merged 1 commit intoSep 22, 2026
Merged
Conversation
yichiche
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
September 10, 2026 12:07
6 tasks done
1am9trash
approved these changes
Sep 15, 2026
1am9trash
left a comment
Collaborator
There was a problem hiding this comment.
Turn tilelang padding from 8 to 16 for rocm MFMA need.
Guard by is_hip(). No impact on nv code path.
6 tasks done
detain
added a commit
to detain/sglang
that referenced
this pull request
Sep 28, 2026
Brings in 113 upstream commits (7ad55e4..d34f7b2). Upstream now contains three stack PRs as merged: sgl-project#40501, sgl-project#40175, sgl-project#33778; every line their squashes add is already present in the stack. Conflicts resolved: - arg_groups/fields/memory.py, managers/cache_controller.py: union of the stack's fast_file backend (sgl-project#39880) and upstream's tensorcast backend. - layers/attention/qsa/mqa.py: keep the stack's SM120 Triton imports and fp8 _scoring_dtype path; adopt upstream's ROCm 16-wide head alignment (sgl-project#38875) and its is_hip import. - models/qwen4_exp.py: all six hunks are stack-only additions (PLE host staging, CUDA-graph prewarm, replay prepare) against upstream's final sgl-project#40501; kept ours. The merged file equals the pre-merge stack version. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
amd-cgilli
added a commit
to amd-cgilli/sglang
that referenced
this pull request
Nov 10, 2026
…age tables - threads=256 and groups_per_cta=4 were tuned on MI355X only; other GPUs keep the default launch (128 threads, fixed CTAs per row). The 16-wide head padding stays on all ROCm GPUs, as on main (MFMA width, sgl-project#38875). - An empty page table gave the page-table-wide grid zero CTAs (hipErrorInvalidConfiguration); return the -inf logits early. - Fix the stale grid comment.
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
Qwen3.8-Flash-Nextcannot serve on ROCm: the TileLang QSA MQA decode kernel fails to compile on gfx950.tilelang_qsa_mqa_decodepads the Q-head dimension up to a multiple of 8, which is the CUDA MMA requirement. ROCm MFMA requires 16. Withindexer_n_heads=4the kernel is asked forN=8and TVM aborts during layout inference:In a real server run this does not surface as the check above. TileLang catches the build failure and retries the outer function through its eager-style path, which re-generates the source without the closure parameters, so the user-visible error is a confusing signature mismatch:
The server dies with SIGQUIT at the first decode step.
Modifications
python/sglang/srt/layers/attention/qsa/mqa.py— select the head-padding alignment per platform: 16 on HIP, 8 elsewhere. The padding is zero-fill and the indexer logit is a weight-free sum over heads, so the padded lanes contribute nothing and the result is unchanged on both platforms. The CUDA path keeps its existing alignment of 8 exactly as before.This change is self-contained in one file and does not depend on any other PR.
Accuracy Tests
Isolated correctness check of
tilelang_qsa_mqa_decodeagainsttorch_qsa_mqa_decodeon gfx950 (heads=4,head_dim=128,page_size=8), comparing only the finite (unmasked) logits:4.77e-07N must be divisible by 16End-to-end on 8x MI355X with the released BF16
Qwen3.8-Flash-Nextcheckpoint (--tp-size 8 --attention-backend aiter --page-size 32 --chunked-prefill-size 16384). This PR is one of the changes required to reach a serving state; the numbers below are for the full ROCm enablement set:No CUDA behavior change, so no CUDA accuracy re-run is required.
Speed Tests and Profiling
Not a performance change — this is a compile-time correctness fix that makes the kernel buildable on ROCm. The zero-padded lanes add 8 extra columns of MFMA work per decode row, which is inside the same MFMA tile that the hardware would issue for
N=16anyway.Checklist
torch_qsa_mqa_decodereference rather than added totest/registered/kernels/test_qsa.py; happy to add a registered ROCm case if reviewers want one.CI States
Latest PR Test (Base): ❌ Run #34474932925
Latest PR Test (Extra): ❌ Run #34474951413
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.