Repository navigation
[Perf] [AMD] attention: Restore the gfx950 extend tile for head_dim <= 128 - #45099
Merged
HaiShaw merged 2 commits intoOct 21, 2026
Merged
Conversation
…= 128 sgl-project#34461 gave the Triton extend-attention kernel a 128-row query tile with 8 warps on gfx950 for every head_dim <= 256. sgl-project#35770 (Kimi-K3 MLA prefill) later restored the older condition, head_dim > 128 only, so head_dim 64 and 128 (gpt-oss, Llama, Qwen) went back to a 64-row tile, while test_extend_attention_block_sizes still expects the wider rule and fails on gfx950. Restore sgl-project#34461's condition. BLOCK_N, and so the reduction order, is unchanged: outputs are bitwise identical.
aarnetalman
marked this pull request as ready for review
October 19, 2026 07:01
aarnetalman
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
October 19, 2026 07:01
4 of 5 tasks
HaiShaw
approved these changes
Oct 21, 2026
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
On MI350X/MI355X (gfx950), the Triton prefill attention kernel used to run faster for models with head size 64 or 128, such as gpt-oss, Llama and Qwen. #34461 made that change, with identical outputs. A later PR (#35770, for Kimi-K3) appears to have undone it by accident, so these models are back on the slower setting. The test #34461 updated still expects the faster setting and fails on MI350X; it runs only on MI300 in CI, so nobody noticed. This PR restores #34461's setting.
@clintg6, was narrowing it intended for the MLA kernels? MLA head dims (576/512, 192/128) take their own branches and are not affected by this change.
Modifications
extend_attention.py(_get_block_sizes_for_extend_attention): restore [ROCm] Extend the gfx950 extend-attention tile to head_dim <= 128: -43% kernel, -14% TTFT, bit-identical #34461's condition and comment,_is_gfx95 and Lq <= 256.BLOCK_Nis unchanged, so outputs stay bitwise identical.test_extend_attention_block_sizesalready expects this.Accuracy Tests
The reduction order (
BLOCK_N) is unchanged, so outputs are bitwise identical; checked at kernel level on MI350X for head_dim 64 and 128 (8k-token chunks after 0-56k-token prefixes, and a mixed 4-sequence batch): output equal to the 64-row tile's withtorch.equal.python3 -m pytest test/registered/attention/test_triton_attention_kernels.py -k extendon MI350X (rocm/sgl-dev:v0.5.22-rocm724-mi35x-20261018): before 3 failed / 5 passed, after 2 failed / 6 passed:test_extend_attention_block_sizesfails before and passes after.test_extend_attentionand the head_dim-80 case oftest_extend_attention_unified_vs_regularfail on MI350X with and without the change (tolerance checks, unrelated).Speed Tests and Profiling
MI350X, Qwen3-8B TP1,
python3 -m sglang.benchmark.serving --backend sglang --dataset-name random --random-range-ratio 1.0 --request-rate inf, before and after alternating twice (pairs within 0.3%), output throughput:--attention-backend tritonNo change off gfx950, for head_dim > 256, or with other attention backends.
Checklist
CI States
Latest PR Test (Base): ❌ Run #39546508413
Latest PR Test (Extra): ❌ Run #39546508460
Latest PR Test (AMD ROCm 10): ❌ Run #39546508338