Skip to content

cuda: tree attention and head dim 512's window rows read keys from a page table (_pg kernels), SASS of the others unchanged - #1618

Merged
ashhart merged 5 commits into
ashhart:mainfrom
jschmied:paged-shared-kernels
Oct 29, 2026
Merged

ashhart merged 5 commits into
ashhart:mainfrom
jschmied:paged-shared-kernels

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

Shared attention kernels read committed keys from a page table, so a family can keep its full-attention caches in pages of the core KV pool (#781). Gemma 4 and Kolibri-1 use them in the two PRs stacked on this one.

  • tree attention: _pg twins of tf_tree_shared* and tf_tree_part* (dims 128 and 256, all block shapes; 12 kernels). Rows.pages: ?Pages = null picks them, null keeps today's launches. Pg moved to common/kv_pages.cuh.
  • window_pages, head dim 512: tf_wrows_part_512_pg + tf_wrows_merge_512_pg (decode) and tf_wrows_prompt_512_pg / _p32_pg (prompt rows, pages a multiple of 32).
  • Pages are passed as an empty template pack and branched with if constexpr. Even an unused Pg argument changed nvcc's SASS of the existing kernels.

Checks (GB10, nvcc 13.0, on main d33dcfc)

  • SASS (tools/zig/cuda_sass_identity.py, main..head, sm_80/86/89/120/121): 430 functions over 4 images, 0 changed, 80 added (60 tree_attention, 20 window_pages), 0 unstable.
  • Byte-equal to the contiguous cache: tree_tests over shuffled pages of 16, 37 and 256 positions (dims 128/256, one-warp and 3-stage blocks); window-pages decode over pages of 16/37/256 and prompt rows over 32/64/256, NaN in every unused slot.
  • Kernel contract: 6 paged tree variants and 6 paged head-dim-512 variants pass repeat, shapes, sums and nonfinite. Four planted controls go red at shapes: an unheld first page (tree, dims 128 and 256), swapped stream tables (512 decode), a later page's id (512 prompt).
  • No SUMMARY line: tf-cuda-test kernel-contract stops at unknown image name: fp8_experts on main too, after the same 220 non-control FAILs (Qwen4 GDN/PLE/HC, weight-only, qwen35 NaN rows), identical by name on main and on this stack. 2088 PASS.
  • Records: measured with cuobjdump -res-usage on the 5 SMs. kernel-contract-limits zig-out/fatbin (-Dsm=80,86,89,120,121): every record this stack adds is current. Its 205 stale records are all in qwen35*, qwen4_*, nvfp4_experts_tile and act_rows.
  • zig build test test-kernel-contract test-golden test-server-security test-pull-security fuzz-cortheon, git diff --check: pass; lean 0 new.

jschmied and others added 5 commits October 29, 2026 23:45
…_pg kernels), SASS of the others unchanged

part_staged takes the pages as an empty template pack: tf_wrows_part_512 and
tf_wrows_merge_512 keep their code, and window_pages.cu adds tf_wrows_part_512_pg
(a key's page from the table at any tok, a staged tile may cross pages) and
tf_wrows_merge_512_pg (merge<512>'s existing PG replay). loadPages loads them into
wide_fns[1].paged; 512 has no paged prompt, so Paged.prompt is optional and
promptRows refuses one. The records copy the base kernels' (regs TODO).

window-pages-512: the 12B, 31B and a GQA 5 shape decoded over shuffled pages of
16, 37 and 256 positions (NaN in every unused slot) give the contiguous bits,
the merge's float64 replay included.
…le (_pg twins), SASS of the others unchanged

window_pages.cu instantiates prompt::kernel<512, P32, NONE, true> as tf_wrows_prompt_512_pg and
tf_wrows_prompt_512_p32_pg; window_rows.cuh is unchanged (its bool PG path already serves 256's
paged prompt). A 32-key tile takes one page base, so promptWith refuses pages whose tok is not a
multiple of 32 (prompt_tile). Paged.prompt is now [bf16 P, P32] like Wide.prompt; 256 keeps bf16 P
only. The records copy the base kernels' (regs TODO).

window-pages-512 adds prompt rows: the 12B and 31B shapes, chunks over many pages starting mid-page
and at a page start, P as bf16 and P32, pages of 32, 64 and 256 (NaN in every unused slot), bit-equal
to the contiguous cache with the float64 replay included, and pages of 48 refused.
@ashhart
ashhart force-pushed the paged-shared-kernels branch from ecee1cc to 69ae32c Compare October 29, 2026 23:45
@ashhart
ashhart merged commit eddc903 into ashhart:main Oct 29, 2026
9 checks passed
@ashhart

ashhart commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is in TensorFold 1.2.0, released today: https://github.com/ashhart/TensorFold/releases/tag/v1.2.0

It landed with your commits under your own name, so you're listed as a TensorFold contributor, and it's credited to you in the release notes and the changelog.

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.

2 participants