Repository navigation
[Triton/Gluon] [GFX950] Use a prefill launch config for sparse MLA launches - #5797
Conversation
The launches were tuned on decode, where rows don't share KV. Prefill rows do, so larger launches cache the gather and widen the LDS row pad.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add coverage for the packed prefill path and correct the decode routing before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Adds GFX950 prefill-specific sparse MLA tuning for cache locality, index prefetching, slot arithmetic, and LDS padding.
Changes:
- Selects prefill launch settings for large query launches.
- Adds pipelined slot-ID prefetching and 32-bit slot arithmetic.
- Applies padded LDS layouts for selected BF16 launches.
| File | Summary |
|---|---|
aiter/ops/triton/attention/sparse_mla.py |
Enables prefill LDS padding. |
aiter/ops/triton/attention/pa_decode_sparse.py |
Selects prefill launch parameters and tuning values. |
aiter/ops/triton/_gluon_kernels/gfx950/attention/sparse_mla.py |
Implements slot prefetching and padded LDS layouts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The split count followed the batch and index-list length, so decode compiled a new kernel pair for each count. The split grid is padded to a multiple of 4, so the reduce compiles for at most 17 counts.
The two-loop case also gets -1 sentinels in its extra lists, so the prefill launch's slot prefetch and 32-bit slot split are checked against the reference.
Addressed the test gap, skipping the config suggestions as this is specialized for gfx950. |
… and tile budget
_decode_num_splits_occ bounds the split count by cta_cap = 2 * num_sms // base_wg,
which lets base_wg * splits exceed num_sms. Capping that alone is not enough: past
a point, cutting splits stops removing overhead and starts removing parallelism.
Sweeping the split count over queries 6..252 x top-k {512, 1024, 2048} on MI355X,
a bare one-wave cap wins 6 of 24 shapes and loses 15, worst -43 %.
Bounding from both sides -- one wave above, tiles // 4 below -- gives 10 wins and
0 losses, worst -1.0 %, best +21.9 %. tiles // 4 is not a new constant: it is the
split floor the base_wg >= num_sms branch of this same function already uses.
Composes with the _MAX_SPLITS cap and _launch_splits padding from ROCm#5797, and helps
their purpose. wave_cap is a power of two, so where it binds the count needs no
padding, and it introduces padding in no cell where main did not already pad.
Over queries 1..256 x top-k {512, 1024, 2048, 8192} it cuts the distinct launched
split counts from 16 to 10, so the reduce compiles for fewer counts, not more.
Adds test_decode_num_splits_occ_bounds, asserting the bounds the split count is
built from over 165 shapes. num_sms is patched rather than read from the device,
so the body allocates nothing and the bounds are checked at partitioned CU counts
(256/128/64/32) as well.
NOTE: the percentages above were measured before ROCm#5797 and have not been re-run
against it. ROCm#5797 changed the launched grid, so they need re-measuring before this
is merged on their strength.
Co-Authored-By: Claude Opus 5 <[email protected]>
… and tile budget
_decode_num_splits_occ bounds the split count by cta_cap = 2 * num_sms // base_wg,
which lets base_wg * splits exceed num_sms. Capping that alone is not enough: past
a point, cutting splits stops removing overhead and starts removing parallelism.
A bare one-wave cap, swept over queries 6..252 x top-k {512, 1024, 2048}, wins 6 of
24 shapes and loses 15, worst -43 %.
Bounding from both sides -- one wave above, tiles // 4 below -- gives 10 wins and
0 losses. tiles // 4 is not a new constant: it is the split floor the
base_wg >= num_sms branch of this same function already uses.
Layers under the tiles <= 2 early return from ROCm#5833, which is the same economics at
the other end -- there the reduce launch outweighs the split, here the per-split
partial write and Q re-read do. These bounds apply from tiles >= 3 up.
Composes with _MAX_SPLITS and _launch_splits from ROCm#5797, and helps their purpose:
wave_cap is a power of two, so where it binds the count needs no padding, and it
introduces padding in no cell where main did not already pad. Over queries 1..256 x
top-k {512, 1024, 2048, 8192} it cuts the distinct launched split counts from 16 to
10, so the reduce compiles for fewer counts, not more.
Adds test_decode_num_splits_occ_bounds, asserting the bounds the split count is
built from over 165 shapes. num_sms is patched rather than read from the device, so
the body allocates nothing and the bounds are checked at partitioned CU counts
(256/128/64/32) as well.
Co-Authored-By: Claude Opus 5 <[email protected]>
NOTE: the percentages above were measured before ROCm#5797 and ROCm#5833, both of which
changed the decode launch. A re-measurement against the current base is running;
this note comes out when it lands.


Add prefill specific tuning to better utilize the locality via L1, index prefetch and improved page index arithmetic.
DeepSeek-V4 (V4-Pro)
128 heads, TP8 -> H=16,
index_topk= 1024.DeepSeek-V4.1 (V4.1-Flash)
64 heads, TP4 -> H=16,
index_topk= 512. Itscompress_ratiosare 0, 1 and 2 only:2 window-only layers, 18 ratio-2 and 20 ratio-1 (plus 3 window-only MTP layers).