Skip to content

[Triton/Gluon] [GFX950] Use a prefill launch config for sparse MLA launches - #5797

Merged
vgokhale merged 3 commits into
mainfrom
cagri/gluon_sparse_mla_fp8_prefill
Sep 24, 2026
Merged

vgokhale merged 3 commits into
mainfrom
cagri/gluon_sparse_mla_fp8_prefill

Conversation

@cagrikymk

@cagrikymk cagrikymk commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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.

layer compression selected + window tokens/query
C4A 4x top-1024 of ctx/4 128 up to 1152
C128A 128x all ctx/128 128 128 + ctx/128
shape layer tokens/query warm main warm this PR warm speedup cold main cold this PR cold speedup
prefill 1 seq x 2k C4A 380 313.7 269.9 1.16x 328.1 278.0 1.18x
prefill 1 seq x 4k C4A 638 618.5 523.1 1.18x 651.2 545.2 1.19x
prefill 1 seq x 8k C4A 895 1,230.6 1,009.0 1.22x 1,327.6 1,079.5 1.23x
prefill 1 seq x 16k C4A 1,023 2,556.4 1,966.8 1.30x 2,669.3 2,150.1 1.24x
prefill 8 seq x 1k C4A 248 1,143.1 1,001.8 1.14x 1,246.5 1,063.4 1.17x
prefill 16k chunk, 128k ctx C4A 1,152 3,022.9 2,002.0 1.51x 3,060.3 2,184.3 1.40x
decode C=2048 C4A 1,152 398.9 334.0 1.19x 414.9 371.4 1.12x
prefill 1 seq x 2k C128A 132 72.8 63.1 1.15x 74.3 64.8 1.15x
prefill 1 seq x 4k C128A 142 137.1 117.7 1.17x 141.0 122.2 1.15x
prefill 1 seq x 8k C128A 159 260.5 225.7 1.15x 266.8 237.9 1.12x
prefill 1 seq x 16k C128A 191 656.6 568.9 1.15x 665.1 599.2 1.11x
prefill 8 seq x 1k C128A 124 257.1 225.7 1.14x 263.1 235.0 1.12x
prefill 16k chunk, 128k ctx C128A 1,088 2,460.3 1,967.6 1.25x 2,577.8 2,143.4 1.20x
decode C=2048 C128A 160 80.9 70.0 1.16x 83.4 99.7 0.84x

DeepSeek-V4.1 (V4.1-Flash)

64 heads, TP4 -> H=16, index_topk = 512. Its compress_ratios are 0, 1 and 2 only:
2 window-only layers, 18 ratio-2 and 20 ratio-1 (plus 3 window-only MTP layers).

layer compression selected + window tokens/query
C2A 2x top-512 of ctx/2 128 up to 640
C1A 1x top-512 of ctx 128 up to 640
SWA - - 128 128
shape layer tokens/query warm main warm this PR warm speedup cold main cold this PR cold speedup
prefill 1 seq x 2k C2A 508 191.2 160.7 1.19x 197.4 166.5 1.19x
prefill 1 seq x 4k C2A 574 376.1 306.3 1.23x 388.6 324.4 1.20x
prefill 1 seq x 8k C2A 607 763.0 595.9 1.28x 796.0 641.3 1.24x
prefill 1 seq x 16k C2A 624 1,603.0 1,188.3 1.35x 1,647.5 1,271.7 1.30x
prefill 8 seq x 1k C2A 376 699.1 587.9 1.19x 747.3 633.2 1.18x
prefill 16k chunk, 128k ctx C2A 640 1,816.1 1,198.5 1.52x 1,867.7 1,300.1 1.44x
decode C=2048 C2A 640 242.0 216.9 1.12x 252.1 255.7 0.99x
prefill 1 seq x 2k C1A 572 196.4 160.6 1.22x 201.9 166.8 1.21x
prefill 1 seq x 4k C1A 606 397.3 309.0 1.29x 409.8 324.9 1.26x
prefill 1 seq x 8k C1A 623 805.4 605.4 1.33x 820.0 642.3 1.28x
prefill 1 seq x 16k C1A 632 1,668.5 1,197.2 1.39x 1,699.4 1,278.8 1.33x
prefill 8 seq x 1k C1A 504 719.0 589.3 1.22x 762.0 637.1 1.20x
prefill 16k chunk, 128k ctx C1A 640 1,852.4 1,215.9 1.52x 1,893.5 1,309.2 1.45x
decode C=2048 C1A 640 246.0 221.6 1.11x 256.5 260.3 0.99x
prefill 1 seq x 2k SWA 124 54.6 48.4 1.13x 54.8 51.2 1.07x
prefill 1 seq x 4k SWA 126 101.7 88.7 1.15x 104.0 94.1 1.10x
prefill 1 seq x 8k SWA 127 191.5 169.8 1.13x 198.2 179.7 1.10x
prefill 1 seq x 16k SWA 128 375.6 337.7 1.11x 376.3 351.3 1.07x
prefill 8 seq x 1k SWA 120 192.4 168.9 1.14x 196.9 179.0 1.10x
prefill 16k chunk, 128k ctx SWA 128 375.6 339.9 1.10x 377.0 351.3 1.07x

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.
@cagrikymk
cagrikymk requested a review from a team September 23, 2026 18:50
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5797 --add-label <label>

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to opt this PR out.

@github-actions github-actions Bot changed the title [TRITON][GLUON][GFX950] Use a prefill launch config for sparse MLA launches [Triton/Gluon] [GFX950] Use a prefill launch config for sparse MLA launches Sep 23, 2026
@cagrikymk
cagrikymk requested a review from vgokhale September 23, 2026 19:11
vgokhale
vgokhale previously approved these changes Sep 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity · 1 Low severity

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.
@cagrikymk

Copy link
Copy Markdown
Contributor Author

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 Medium severity · 1 Low severity

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.

Addressed the test gap, skipping the config suggestions as this is specialized for gfx950.

@vgokhale
vgokhale merged commit d3c5ddc into main Sep 24, 2026
70 checks passed
@vgokhale
vgokhale deleted the cagri/gluon_sparse_mla_fp8_prefill branch September 24, 2026 18:47
tianxiaojiang4 added a commit to tianxiaojiang4/aiter that referenced this pull request Sep 25, 2026
… 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]>
tianxiaojiang4 added a commit to tianxiaojiang4/aiter that referenced this pull request Sep 25, 2026
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants