Repository navigation
[AMD] Fix Triton 3.7 gfx950 extend-attention spills - #34741
Merged
Merged
Conversation
Use the N32 tile for Lq576/Lv512 to eliminate scratch spilling without regressing Triton 3.6, with selection and numerical coverage.
kkHuang-amd
requested review from
BBuf,
DarkSharpness,
HydraQYH,
celve and
yuan-luo
as code owners
August 13, 2026 12:57
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Triton 3.7-specific gfx950 tile configuration to prevent register spilling for Lq=576/Lv=512 extend attention.
Changes:
- Selects a 64×32 tile for the affected configuration.
- Adds tile-selection and numerical-equivalence tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/sglang/kernels/ops/attention/extend_attention.py |
Adds Triton version detection and the gfx950 workaround. |
test/registered/attention/test_triton_attention_kernels.py |
Tests configuration selection and numerical accuracy. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
HaiShaw
approved these changes
Aug 14, 2026
HaiShaw
left a comment
Collaborator
There was a problem hiding this comment.
triton3.7 and _gfx95 specific changes
5 tasks
This was referenced Aug 15, 2026
saturn-acc
pushed a commit
to saturn-acc/sglang
that referenced
this pull request
Aug 16, 2026
This was referenced Aug 19, 2026
5 tasks
This was referenced Aug 21, 2026
Atituiset
pushed a commit
to Atituiset/sglang
that referenced
this pull request
Sep 10, 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.
Use an N32 tile for the gfx950 Lq576/Lv512 extend-attention specialization on Triton 3.7+ to eliminate register spilling and recover Kimi-K3 prefill performance, while preserving the existing Triton 3.6 configuration.
Motivation
On MI355X/gfx950, Triton 3.7 regresses the
extend_attention.py::_fwd_kernelspecialization forLq=576,Lv=512,BLOCK_M=64,BLOCK_N=64, andnum_warps=4:Reducing
BLOCK_Nto 32 preservesBLOCK_Mand the launch grid while lowering KV-tile register pressure.Modifications
triton.__version__.(BLOCK_M, BLOCK_N, num_warps) = (64, 32, 4)forLq=576/Lv=512when using Triton 3.7+.(64, 64, 4)tile for Triton 3.6 and all non-matching architectures/shapes.Lq=576/Lv=512shape.Accuracy Tests
Focused correctness:
test_extend_attention_block_sizes: passed.test_extend_attention_triton37_lq576_n32: passed.0.00390625(atol=2e-2,rtol=1e-2).Full GSM8K control (1319 requested examples; 5 are reserved for few-shot prompting, so 1314 are scored):
The candidate does not regress full-set GSM8K accuracy. Maximum token capacity remains
933883.Speed Tests and Profiling
Environment:
Isolated matched late-prefill shape (
B=2, extend lengths[8192, 7661],Hq/Hkv=12/1,Lq/Lv=576/512):The candidate improves isolated p50 by 58.3% and removes all scratch spilling.
Serving benchmark: random 8192-input/1024-output requests, 64 warmups, no radix cache.
The N32 tile restores the full C2-C32 endpoint matrix. Triton 3.6 retains N64 because N32 regresses the isolated Triton 3.6 shape by 17.2% (5.34 ms to 6.26 ms).
Checklist
pre-commit run --all-filespasses.)Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #31702557591
Latest PR Test (Extra): ❌ Run #31703233934