Repository navigation
cuda window attention: a decode row merges and computes partials only over chunks it has keys in - #3123
Open
ashhart wants to merge 6 commits into
Open
cuda window attention: a decode row merges and computes partials only over chunks it has keys in#3123ashhart wants to merge 6 commits into
ashhart wants to merge 6 commits into
Conversation
Owner
Author
|
GB10 results on this head:
We're on both.
|
ashhart
force-pushed
the
lead/window-rows-live-chunks
branch
2 times, most recently
from
November 13, 2026 20:20
24a9c26 to
7683b1c
Compare
ashhart
added a commit
that referenced
this pull request
Nov 13, 2026
…ols (the live-chunk count, as the kernels they mirror)
4 tasks done
ashhart
added a commit
that referenced
this pull request
Nov 18, 2026
…ols (the live-chunk count, as the kernels they mirror)
ashhart
force-pushed
the
lead/window-rows-live-chunks
branch
from
November 18, 2026 19:43
ad68ae2 to
3936d28
Compare
ashhart
added a commit
that referenced
this pull request
Nov 21, 2026
…ols (the live-chunk count, as the kernels they mirror)
ashhart
force-pushed
the
lead/window-rows-live-chunks
branch
from
November 21, 2026 11:57
3936d28 to
fa0fb87
Compare
ashhart
added a commit
that referenced
this pull request
Nov 22, 2026
…ols (the live-chunk count, as the kernels they mirror)
ashhart
force-pushed
the
lead/window-rows-live-chunks
branch
from
November 22, 2026 01:32
fa0fb87 to
280baa9
Compare
… keys in With no window, chunk c holds keys [c * 256, c * 256 + 256), so every chunk past a row's own position is empty and its partial is m = -inf, l = 0. The merge now loops to min(chunks, pos / 256 + 1) instead of every chunk: 4 chunks instead of 128 for a row at position 1000 of a 32K context. An empty chunk changes neither of the merge's loops (the max ignores -inf and the sum skips it), so every output byte is unchanged; a windowed row keeps every chunk. The one merge template serves the 256 and 512 kernels, the paged kernels and the contract's controls. The planted faults move to window_rows_fault.cuh beside liveChunks, with ALL (every chunk, as before) for the new tf_ctl_wrows_merge_all_256 and _512 controls. Four contract registrations (head dims 512 and 256, no window, contexts 32768 and 131072, rows at positions 0, 255, 256, 1000 and 32767) run the bounded merge and the all-chunk merge on the same partials and require byte equality.
…, grid z fixed by the row count part and part_staged ran one block a chunk, grid z = the context's chunks (128 at 32K, 512 at 128K), most of them empty for a row early in its context. Each block now loops c = blockIdx.z; c < live; c += gridDim.z over the row's live chunks (with no window, those up to its position; a window keeps every chunk) and calls the unchanged body, part_one or part_staged_one, which now takes c and the chunk count instead of reading them from the grid. Grid z is partBlocks(rows, key heads x head pairs, chunks): about 1,024 blocks a launch, from the row count and the model's head shape alone, so a captured decode graph stays valid as positions move. Each written chunk's partial has the bytes the one-block-a-chunk launch wrote; chunks past a row's live ones are no longer written, and the bounded merge never reads them. The kernels take the chunk count after scale (before the page arguments). tf_ctl_wrows_part_all_256 and _512 write every chunk as before, and the equality registrations now compare the bounded partials and merge against the all-chunk partials and merge, byte for byte.
…B10 register records
The four equality registrations served exactly five rows (one a test
position) and refused any other count, but gate 4 (gates.sums) runs a
served shape's first four rows at most, so it was refused ("refused a
served shape"). They now take up to five rows, their positions' first
ones, and the positions are ordered so gate 4's four keep the longest
row (32767) and both chunk edges (255, 256); gates 1 to 3 still run all
five.
The partials' stride loop raised the decode kernels' registers on
sm_120/121: the work that does not depend on the chunk (the row's
position, slot and window, its query and base pointers) is computed
once before the loop and kept live across every chunk and barrier,
where the one-chunk body computed and dropped it. The records take the
GB10's counts: tf_wrows_part_256 104 -> 128, tf_wrows_part_512 125 ->
128, tf_wrows_merge_512 62 -> 64, tf_wrows_part_256_pg 108 -> 127,
tf_wrows_part_512_pg 122 -> 128. No occupancy changes: the 256-dim
partials stay at two blocks an SM (46,208 B of shared memory each, and
2 x 256 x 128 registers fit 65,536), the 512-dim at one (82 KiB), the
merge at four.
…tials (full kernel contract on GB10)
…ols (the live-chunk count, as the kernels they mirror)
ashhart
force-pushed
the
lead/window-rows-live-chunks
branch
from
November 26, 2026 15:21
280baa9 to
aa456cc
Compare
This branch has not been deployed
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.
CUDA decode attention (
window_attention, shared by Qwen3.5/3.8, Llama, MiniMax-M3, Spark 2.5, Step5 and LFM):window_rowsmerged every chunk's partial for every row, 128 chunks at the default 32K context, though a row at position p only has keys in the chunks up to p/CK. Two commits:Tests:
test-window-rows-host10/10;test-runtime-host329 after part 1 and 330 after part 2;compile-cuda-testspasses; CUDA source and fragment checks clean.Device check pending (GB10):
tf-cuda-test kernel-contract window_rows window_pages(the 4 new equality cases byte-equal, controls red),tf-cuda-test window-rows,kernel-contract-limitswith register records updated if the kernels moved, and a Qwen3.8-27B decode A/B with long contexts and equal token hashes.