Skip to content

[Triton/Gluon] Window-aware split-KV for sliding-window attention - #6899

Closed
okorzh-amd wants to merge 5 commits into
ROCm:mainfrom
okorzh-amd:okorzh/ua-sw-window-split
Closed

okorzh-amd wants to merge 5 commits into
ROCm:mainfrom
okorzh-amd:okorzh/ua-sw-window-split

Conversation

@okorzh-amd

Copy link
Copy Markdown
Contributor

Motivation

Follow-up to #6889, as suggested in its review: do the split and the reduce in a window-aware way.

#6889 splits a sliding-window spec-decode verify on gfx950 only when max_seqlen_k is within the window bound, window + q + block_size - 2. That means a block table trimmed to the window, or a batch whose contexts are all that short. Stock vLLM does not trim. Only a vLLM fork branch does (okorzh-amd/vllm okorzh/rocm-aiter-fa-swa-verify-trim, behind VLLM_ROCM_AITER_FA_SWA_VERIFY_TRIM=1).

The bound exists because every split-KV launch divides [0, seq_len) into NUM_SEGMENTS tile ranges. Over an untrimmed long context only the few segments that overlap the window do work, and the rest are empty. For W 2048, q 8 that is 5 of 64 segments at ctx 32768 and 1 of 64 at ctx 200000. #6889 measured it: forcing the split over a full table took 12.3-37.6 us, against 29.0-30.5 us unsplit.

This PR carves only the window, so a full table gets the same split as a trimmed one.

Stacked on #6889. Only the last commit (fd3d75a884) is new. The diff will shrink to that commit once #6889 merges.

Changes

The carve, for SLIDING_WINDOW > 0: no row of a sequence can see a key before row 0's first one, context_len - SLIDING_WINDOW + 1. Each sequence therefore splits only the tiles [tile_lo, cdiv(seq_len, TILE_SIZE)), with tile_lo = max(context_len - SLIDING_WINDOW + 1, 0) // TILE_SIZE. Then tiles_per_split = cdiv(window_tiles, NUM_SEGMENTS), and split s starts at tile_lo + s * tiles_per_split.

  • The inputs are per sequence (seq_len, query_len), so every query block of a sequence and the reduce agree.
  • TILE_SIZE is 64 on every gfx950 sliding-window split (the kv_split entries pin it).
  • tile_lo is 0 for any context up to window + 62, which includes every context shorter than the window. Then the carve is exactly the old one.
  • The gluon kernel already skipped computing tiles before each query block's window. What changes is how the window's tiles are distributed across segments.

Per file:

  • aiter/ops/triton/_gluon_kernels/gfx950/attention/unified_attention.py: AttentionProgram.initialize carves by window when SLIDING_WINDOW > 0. The no-window branch is unchanged. The empty-split store and [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 #6889's split-0 sink fix stay as they are. The store still fires exactly for the segments the reduce reads.
  • aiter/ops/triton/_triton_kernels/attention/unified_attention.py:
    • A new split_window_tiles helper gives kernel_unified_attention_3d and reduce_segments the same window tile range. Each kernel still derives tiles_per_segment itself, and the gluon kernel keeps its own copy of the carve.
    • kernel_unified_attention_3d carves by window when SLIDING_WINDOW > 0. It is unreachable with a window today, but it pairs with the same reduce.
    • reduce_segments gets SLIDING_WINDOW: tl.constexpr = 0. With a window it reads query_len from cu_seqlens_q and computes the same carve to mask the unwritten segments.
  • aiter/ops/triton/attention/unified_attention.py:
    • _reduce_segments_triton passes SLIDING_WINDOW=params.sliding_window.
    • _unified_attention_3d_gfx1250 asserts sliding_window <= 0. Its split still carves [0, seq_len), and use_2d_kernel never sends a sliding-window call there.
    • _gfx950_split_grid no longer requires max_seqlen_k to be within the window bound. The q <= 16 and q * num_queries_per_kv <= 128 gates stay.
    • The skip_reduce return documents that sliding-window partials follow the window carve.
  • aiter/ops/triton/utils/unified_attention_utils.py: the kv_len = min(max_seqlen_k, sliding_window + max_seqlen_q - 1) clamp in compute_segment_params applies to every sliding-window lookup. It now matches what the split covers, to within one tile (see Known limitations). It now also reaches decode and the non-gluon tables, with no effect: decode is capped at one segment, and those backends never split with a window. sliding_window_bounds_kv and the SWB axis are removed.
  • aiter/ops/triton/configs/gfx950/gluon/attention/unified_attention/DEFAULT.json: SWB leaves the kv_split schema, and SW_GEQ_256.SWB becomes SW_GEQ_256.Q_GEQ_2 with the same values. Sliding-window decode (q == 1) still lands on the bare SW entry, MAX_SEGMENTS 1.
  • op_tests/triton_tests/attention/test_unified_attention.py:
    • test_triton_unified_attn_sw_verify_split: the two full-table rows now expect the same split as their trimmed tables ([32, 32], [64, 64]). When the trim is a whole number of tiles, full and trimmed outputs must be bit-identical. Of the changed rows, that applies to the block-128 one.
    • New test_triton_unified_attn_sw_split_carve (24 cases, GPU). It forces a split on the gluon and the triton producer, with partial buffers filled with NaN. It runs over verify rows, sequences with several query blocks whose window and causal edges fall inside a tile, and a decode-only batch. It checks the output against the reference. From segm_max it also checks that exactly the segments the window carve gives each sequence are written.
    • test_unified_attn_sw_kv_split_config (CPU): the two rows one key past the old bound and far past it (W 2048, q 8, ctx 2071 and 200000, B 1) now expect 64 segments instead of 1. [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 #6889's "one key past the bound stays unsplit" check is gone by design. The test also gains untrimmed rows and a capped decode row.
    • test_unified_attn_sw_axis_lookup (CPU) now also checks which entry verify and decode land on.

What does not change

  • No-window kernels: the gluon kernel, kernel_unified_attention_3d and reduce_segments compile to the same gfx950 instruction stream as before. This was checked for the specialization compiled: 16 q / 2 kv heads, head 64, block 16, bf16, sinks, 8 segments. They were compiled without a GPU and only the debug line info differs.
  • Dispatch: a no-launch CPU dispatch sweep compares the grid (2d or split), NUM_SEGMENTS, TILE_SIZE, the reduce config and the attn_2d/attn_3d configs for both backends. It covers 3,692,160 shapes per arch, base [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 #6889 head (584fe297fa) vs this PR.
    • Sweep grid: windows 0, 64, 128, 255-257, 300, 500, 512, 1024, 2048, 4096 and 32768; q 1-128; B 1-128; 4 head layouts; D 64/128/256; bf16/fp8; block 16-256; ctx from below the window to 200000.
    • gfx950: 75,220 shapes change. Every one is a gluon sliding-window call with 1 < q <= 16 and a context past the old bound, going from 2d to split.
    • Each of them gets exactly the dispatch [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 #6889 gave the same call at the bound: grid, NUM_SEGMENTS, TILE_SIZE and reduce config.
    • By window: 256: 6,156; 257: 6,156; 300: 5,832; 500: 9,180; 512: 9,180; 1024: 11,664; 2048: 10,892; 4096: 11,312; 32768: 4,848.
    • Nothing else changes: no-window calls, decode, q > 16, windows below 256, contexts within the old bound, and the triton backend.
    • gfx1250 and gfx1100: 0 changes. gfx1100 has no gluon tables, so only its triton configs were compared. Other arches were not swept; by code reading a sliding-window call never reaches a split there.
  • Trimmed tables: the grid is unchanged. With block 16 or 64 the carve is unchanged too, because tile_lo is 0. With block 128 a trimmed table can start up to one tile before the window, and with block 256 up to three. The split no longer counts those tiles, so segment boundaries shift. Results can differ by bf16 rounding there (not measured).

Test plan / results

  • CPU, pytest -k "sw_kv_split_config or sw_axis_lookup": 19 passed (gfx950 driver faked). Each of these dispatch mutants fails at least one case: decode uncapped, the 256 threshold removed, the clamp removed, the clamp gated on the old bound, the LEQ/GEQ guard removed.
  • GPU-less compile for gfx950 of the window and no-window variants of all three kernels. A deliberately broken window branch fails to compile.
  • kernel_unified_attention_3d + reduce_segments under TRITON_INTERPRET=1: 42/42 within 3.9e-7 of an fp64 sliding-window + sink reference. These were direct fp32 launches with NaN-filled partials, at small shapes. The cases cover decode, several query blocks, more segments than window tiles, sinks on and off, and the SEGMENT_BLOCK reduce path. With the reduce kept on the old carve, 34/42 fail. This covers the triton producer only. The gluon producer has compile-only evidence until the GPU tests run.
  • GPU (MI355X): pytest op_tests/triton_tests/attention/test_unified_attention.py -k sw_ (sw_verify_split 6 cases, sw_split_carve 24 cases).
  • GPU (MI355X): the full test file, against [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 #6889's baseline.
  • Perf A/B against [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 #6889, below.

Performance

Not measured yet. The expectation is that an untrimmed verify gets the trimmed-table times from #6889's table. The grid is now the same, and each split covers the same number of window tiles; the same keys only when the trim is a whole number of tiles. From that table (W 2048, q 8, 16 q / 2 kv heads, head 64, bf16, block 16, ctx 32768, measured on an image with #6594), full-table base vs trimmed split:

  • B 1: 29.0 -> 6.7 us
  • B 32: 30.5 -> 25.1 us

Planned A/B (MI355X, CUDA-graph replay, base = #6889 head):

  1. Untrimmed long contexts: ctx at the first value past the old bound, 2W, 32768 and 200000.
    • W 256, 512, 1024, 2048, 4096 and 32768; q 2, 8 and 16; block 16 and 128.
    • B up to the first one that goes 2d.
    • Layouts: 16/2 head 64 (bf16 and fp8), 16/2 head 128 and 256, 4/2 head 128, 8/1 head 64, 64/8 head 64.
  2. FULL-graph capture emulation (see Known limitations): max_seqlen_k = 131072 at capture, real ctx 64-2100, B 1-33.
  3. The batch sizes where the split stops (SPLIT_SEQS_PER_TILE) for layouts other than 16/2 head 64, which is the layout the factor was fitted on.

Known limitations

  • FULL CUDA-graph capture.
    • The split is chosen on the host from max_seqlen_k at capture. Before this PR, stock vLLM ran every sliding-window verify whose max_seqlen_k exceeded window + q + block_size - 2 on the 2d grid. That includes a FULL graph captured at a long max_seqlen_k.
    • Now a verify that the dispatch splits (W >= 256, q <= 16, small B, e.g. B <= 32 for 16/2 head 64 at W 2048, q 8) and that is captured at a large max_seqlen_k splits at every replay, whatever the real contexts are.
    • [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 #6889 measured that split as 1.27-1.86x slower at real ctx 300 and B 12-32, and 1.05-1.49x slower at ctx 500. That limitation used to apply only to the vLLM trim branch; it now applies to stock vLLM too.
    • The A/B above has to show this is acceptable, or the PR needs a gate. A cheaper gfx950 reduce, or a decision made on the device, could remove it; a host dispatch rule cannot.
  • skip_reduce. With a window, the partials it returns follow the window carve, not [0, seq_len). No in-repo caller passes skip_reduce with a window. In vLLM the only skip_reduce user is the MLA segmented decode, which has no window.
  • Reduce variants. reduce_segments takes SLIDING_WINDOW as a constexpr, so a model with several window sizes compiles one reduce variant per window. The producers already specialize on it.
  • Tile count. compute_segment_params counts cdiv(window + q - 1, 64) tiles. The carve can span one more whenever the window's first key is not 64-aligned, e.g. W 2048 at q 8 counts 33 where the carve can span 34. That changes NUM_SEGMENTS only when cdiv(window + q - 1, 64) is a power of two, e.g. W 2047 at q 2 (32 vs 33): tiles_per_split becomes 2 and about half the segments are empty. Power-of-two windows at q >= 2 avoid it, and trimmed tables at base had the same count. The sweep did not include such windows.
  • gfx1250 and decode. gfx1250 keeps the old carve, behind an assert. Sliding-window decode stays capped at one segment. Both could follow, decode with timings first.

okorzh-amd and others added 3 commits October 23, 2026 13:29
On gfx950 a sliding-window call with q > 1 never takes the split grid
(_gfx950_split_grid returns False, and kv_split["SW"] caps MAX_SEGMENTS
at 1), so a spec-decode verify on a sliding layer runs num_kv_heads
programs per sequence over the whole window. Splitting it only pays once
the KV range is cut to the window: the split carves seq_len, so over a
full context the window lands in one or two segments and the rest are
empty (31.9-37.6 us vs 29 us unsplit when forced).

Split only when the KV range is bounded by the window. Row i of a q-row
sequence of length L reads keys from L - q + i - (SW - 1) on, so a block
table trimmed to whole pages holds at most SW + q - 1 + block_size - 1
keys. The new SWB config axis is sliding_window_bounds_kv(): q > 1 and
max_seqlen_k <= sliding_window + max_seqlen_q + block_size - 2. A batch
whose contexts are all that short is bounded as well, trimmed or not, and
takes the same path. _gfx950_split_grid lets verify-sized SWB calls
(max_seqlen_q <= 16 and max_seqlen_q * num_queries_per_kv <= 128)
through and then decides like any other batch (NUM_SEGMENTS > 1).
Longer queries (prefill chunks) keep the 2d grid: with q rows per
sequence in the reduce, MHA q = 128 at window 256-512 ran up to 1.33x
slower split.

The gfx950 gluon kv_split table gains an "SW.SWB" entry, the SW entry
without its segment cap, plus:
- SPLIT_FIT_BUDGET (new): the largest power-of-two split that keeps the
  launch within SEGMENTS_PER_CU (1) programs per CU, sized by the real
  one-block-per-sequence query grid (_gfx950_split_params). The default
  ceil-rounded share splits 2 ways up to B = 51 and loses 30-40% from
  B = 36 (39.7-43.0 us vs 30.4-30.8 us on the 2d grid).
- SPLIT_KV_WINDOW (new): count the KV tiles over the sliding_window +
  max_seqlen_q - 1 keys the rows can see, not the page slack of a trimmed
  table, so SPLIT_MIN_TILES 4 keeps window 128 unsplit at block 128 too
  (64 q / 8 kv heads, q = 4: 8.2 us split vs 6.7 us 2d).
- SPLIT_SEQS_PER_TILE 1.5 (new): no split once num_seqs exceeds 1.5 x the
  KV tiles. The triton reduce_segments pass that every gfx950 split pays
  costs more with the batch (7.6 us at B = 32, 2 segments), while the 2d
  kernel's time follows the KV length, so at windows 256-1024 a split at
  B = 12-32 ran up to 1.87x slower than the 2d grid.

Kernel: a split whose tiles all fall before the window start stores an
empty partial, and split 0 is the only one that counts the attention
sink, so a window starting past tile 0 (block size > 64, or a shorter
row in an untrimmed bounded batch) dropped the sink from the softmax.
The empty-partial path of split 0 now stores M = sink, L = 1.

Unchanged dispatch: SW calls with a context past the bound, SW decode
(q == 1 keeps the cap), q > 16, window 128, full attention, gfx1250 and
the triton backend. Of 328,800 no-launch shapes (window 128-32768, q
1-128, B 1-128, 5 head layouts, D 64-256, bf16/fp8, block 16-256,
ctx bound -300..+5000) only gluon SW calls with 1 < q <= 16 inside the
bound change grid (22,392).

MI355X, 16 q / 2 kv heads, head 64, bf16, block 16, window 2048, q = 8,
ctx 32768 (us per call, CUDA-graph replay, natural dispatch):
  B           1     2     4     8    16    32    48    64
  full      29.0  29.0  29.1  29.5  30.0  30.5  30.6  30.9
  trimmed    6.7   7.2   8.6  10.9  15.8  25.1  30.6  30.8
  segments    64    32    16     8     4     2    2d    2d
Full-attention floor at 2056 keys: 6.6 / 6.8 / 8.1 / 9.4 / 14.4 / 21.9.
The natural pick matches the fastest forced count (1-128) at every B.
Shorter windows, trimmed, same heads (base 2d -> split, us):
  W 512:  B4 9.78 -> 6.79, B8 9.79 -> 7.61, B12 9.82 -> 9.19, B16+ 2d
  W 1024: B4 16.30 -> 7.66, B8 16.35 -> 8.61, B16 16.71 -> 12.27, B32 2d
  W 256:  B4 6.54 -> 6.30, B8+ 2d

Known cost: a caller that captures a graph at max_seqlen_k = window bound
and replays it for batches whose real contexts are a few hundred keys
pays the split + reduce where the 2d kernel was cheaper (B >= 12, ctx <=
1000). A cheaper gfx950 reduce would remove that.

Test: test_triton_unified_attn_sw_verify_split (full and trimmed tables
vs reference with a dominant sink, exact segment counts: trimmed verify
splits, full context stays 2d, SW decode stays 1 segment, q = 17 and
q = 128 prefill chunks stay 2d, block 128 and an untrimmed bounded batch
leave split 0 empty) and test_unified_attn_sw_kv_split_config
(CPU-only kv_split picks at the bound edge, untrimmed, decode, window 128,
and the batch sizes where the split stops).

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up. The SPLIT_KV_WINDOW knob was set only in the SW.SWB
entry, so it configured nothing. compute_segment_params now counts KV
tiles over the sliding_window + max_seqlen_q - 1 keys the rows can see
whenever sliding_window_bounds_kv() holds, with no config switch.

The clamp is gated on the bound, not on sliding_window > 0. The split
carves the whole seq_len, so on an untrimmed long context a window-sized
count leaves most segments idle. No unbounded sliding-window call reaches
a split lookup today, so the two gates pick the same grid.

CPU dispatch sweep vs the previous commit, 2,048,256 shapes per arch on
gfx950 (gluon and triton), gfx1250, gfx1100 and gfx1201: no 2d/3d,
NUM_SEGMENTS or TILE_SIZE change. 1,184 gfx950 gluon shapes change only
the triton reduce num_warps (head 256, block >= 64, window + q - 1 of
about 257-512), since the reduce lookup now sees the same clamped length.
test_unified_attn_sw_kv_split_config: 11 passed on CPU; removing the clamp
fails the window 128, block 128 case.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up. The SW axis was a bool, so a table could not target a
window size. SW is now "opt_num": the keys a row can see,
min(sliding_window, max_seqlen_k), floored at 1, and 0 with no window.
SW_EQ/LEQ/GEQ_<n> keys pick by size, a bare SW matches any window, and
no window matches only "any". Tables that only use a bare SW key (gfx950
gluon and triton, gfx1250 gluon, gfx1201 triton) resolve as before.
_index rejects a table that mixes SW_LEQ and SW_GEQ keys, because every
matching LEQ key would outrank every GEQ key. It is cached on the key
names, so the check runs once per table.

The gfx950 gluon kv_split entry SW.SWB becomes SW_GEQ_256.SWB. Bare SW,
with MAX_SEGMENTS 1, stays the fallback for every other window and for SW
decode. 256 keys is 4 tiles of 64, the smallest window measured to win.
Window 128 now falls back through the threshold, not SPLIT_MIN_TILES.
SWB stays: an untrimmed long context also gives SW = window, and
splitting that table was measured slower.

CPU dispatch sweep vs the previous commit, 3,692,160 shapes per arch
(grid, NUM_SEGMENTS, reduce config, and attn_2d/attn_3d configs for both
backends) on gfx950, gfx1250, gfx1100 and gfx1201: the only change is
6,300 gfx950 gluon shapes at window 255 (q 4-16, just under the
threshold), split -> 2d. Windows above 2048 still split; their perf is
not measured.

Tests: test_unified_attn_sw_kv_split_config gains window 255 vs 256 at
the threshold and window 256 at block 128 (the clamp case).
test_unified_attn_sw_axis_lookup covers the candidate order, the axis
value and its floor, and the LEQ/GEQ guard. 15 passed on CPU. Each of
these mutants fails at least one test: threshold, clamp, guard, bare-SW
fallback, the no-window check, min(), and the floor.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu 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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 6899 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

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 stop the title rewrites; labels stay in sync either way.

okorzh-amd and others added 2 commits October 24, 2026 01:23
Review follow-up (Copilot). A sliding-window split over a bounded table
whose page is much longer than a tile can leave 32 or more empty leading
segments, which store M = -inf. One example is head 256, q 8, KV 10246,
window 2048, block 8192, 64 segments. At head 256 reduce_segments merges
in SEGMENT_BLOCK = 32 chunks. Without sinks the first chunk then has no
finite max, and exp2(-inf - -inf) turned alpha and weight into NaN for
the whole row. With sinks, split 0 stores the sink and hides it.

Rescale an all-empty chunk from 0 instead, so alpha and weight are 0. A
chunk with a finite max computes exactly as before, and the single-chunk
reduce (head <= 128) compiles to the same instructions.

Under TRITON_INTERPRET=1, reduce_segments on the partials that both
Copilot shapes leave gives NaN on every row with 32+ leading empty
segments before this change. After it, no NaN, within 6e-8 of the
single-chunk reduce. test_triton_unified_attn_sw_split_no_sinks runs both
shapes on gfx950 (head 256, no sinks) and checks the 64-segment split
and the output.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With a sliding window, every split-KV launch carved [0, seq_len) into
NUM_SEGMENTS tile ranges. Over an untrimmed long context the window lands
in one or two segments and the rest are empty. That is why ROCm#6889 split
only window-bounded (trimmed) tables.

Carve only the window instead. For SLIDING_WINDOW > 0, each sequence
splits the tiles [tile_lo, cdiv(seq_len, TILE_SIZE)), where tile_lo is
the tile of row 0's first visible key, max(context_len - SLIDING_WINDOW
+ 1, 0) // TILE_SIZE. It is per sequence, so every query block and the
reduce agree. The gfx950 gluon split, the triton kernel_unified_attention_3d
and reduce_segments all carve this way (the triton pair shares
split_window_tiles). reduce_segments gets SLIDING_WINDOW from the launch.
The gfx1250 3d wrapper asserts no window, since its split still carves
seq_len and use_2d_kernel never sends a window there. With no window,
all three kernels compile to the same gfx950 instructions as before.

Dispatch: an untrimmed table now splits like a trimmed one.
_gfx950_split_grid drops the bound check and keeps the q <= 16 and
q * num_queries_per_kv <= 128 gates. The kv_len clamp applies to every
sliding-window call. The SWB axis and sliding_window_bounds_kv are gone,
and the split entry is SW_GEQ_256.Q_GEQ_2, so sliding-window decode stays
on the capped bare SW entry. CPU dispatch sweep vs the parent commit,
3,692,160 shapes per arch: on gfx950 the only change is 75,220 gluon
sliding-window calls with 1 < q <= 16 past the old bound going 2d ->
split. gfx1250 and gfx1100 do not change.

Tests: the verify-split grids for full tables become splits, and a
whole-tile trim must give bit-identical output. The new
test_triton_unified_attn_sw_split_carve forces gluon and triton splits
with NaN-poisoned partials over verify, multi-query-block and decode
batches. It checks the output and that exactly the window carve's
segments are written. CPU config rows cover untrimmed contexts and the
capped decode. GPU runs are pending.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@okorzh-amd
okorzh-amd force-pushed the okorzh/ua-sw-window-split branch from fd3d75a to 0733d76 Compare October 24, 2026 06:29
@okorzh-amd

Copy link
Copy Markdown
Contributor Author

Closing: per review, the window-aware split is now folded directly into #6889 (same source change), so this follow-up isn't needed.

@okorzh-amd okorzh-amd closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant