Repository navigation
Conversation
…shhart#1762) and add+norm under 1 %, direct load for Gemma 4 and Qwen 3.5 (ashhart#2282), Nemotron's done, q27 Metal pages (ashhart#2283)
|
Thanks @jschmied. Lifting the page row, page tensor and twin source edits into
Kept states as pool pages stay with #2215's walk, as planned on #1293. |
…TF_QWEN27_METAL_KV_PAGES=1 (ashhart#2283)
|
Thanks @ashhart. All four are in, as new commits on top. The head is 35e3d98.
On this head: |
…edits shared in kernels/metal/core Nemotron's and Qwen3.5's paged kernels each carried the same page-row formula; Nemotron also carried the page tensor and the count-checked comptime source edits. They move to kernels/metal/core (tf_paged_row in kv_pages.h, tf_page_tensor in kv_page_tensor.h, source_edit.zig) and both families call them, so a third family's twins reuse them. No kernel's arithmetic or addressing changes.
…N27_METAL_KV_PAGES=1 With the flag on, every slot's K/V rows live in one arena of 256-row core-pool pages, slot i its lane i, promised its whole window (the Fit already charges each slot that). The attention kernels' twins (kernels/metal/qwen27/paged.zig) are main's sources with only the K/V address edited, by count-checked edits through the shared source_edit, tf_paged_row and tf_page_tensor; their names stay, so a paged runner builds one library in place of main's. Each stream's read pointers gain its table and page size. A pass covers its rows' pages first, a keep trims the dropped rows' pages, snapshots and the digest read page by page in main's byte order, and every page is free again at close. Flag off, nothing changes. tf-qwen27-attention-pages runs main's kernels and the twins on the same rounds (decode, trees with a keep, four streams across page edges, the prompt kernel) through shuffled pages: outputs and every cache row the same bits.
…give main's digests (tf-qwen27-pages-resume)
…S=1 by name until the paged kernels run on an M5
…TF_QWEN27_METAL_KV_PAGES=1 (ashhart#2283)
…hrough the stream's table Main's masking (08a4839 to 9be323a: the masked prefix and prompt kernels and the prompt scan) added value reads by head stride and key that the twins' edits did not reach, so under TF_QWEN27_METAL_KV_PAGES=1 the scans and the masked rows read the wrong rows. The prefix's and prompt kernels' scans (q27_nonfinite_paged, derived from main's by edit), the masked prefix's value rows and q27_attn_prompt_scan now find each key's row in its page; every edit stays count-checked against main's text. Main's two new callers of simd_attention.grouped (the pick test, the q27 rows contract) pass paged = false. tf-qwen27-attention-pages gains rounds that plant Inf, -Inf and NaN in values a window's first row must not see, and --shared-prefix runs the M5's plan (prefix kernels over every row's keys) on any chip. On an M3 Pro both modes pass bit for bit, and each new edit reverted alone fails a planted round.
35e3d98 to
615d153
Compare
|
Rebased onto The rebase needed code, not only a merge.
Dropping each new edit alone fails the tool: both prompt scans at round 19; the masked V row and the prefix scan with Three limits:
Timings re-run, since the scan runs on every prompt pass. ABBA, medians of 3, same Mac, in daily use:
Flag on against flag off is +1.2 % on prefill and −1.4 % on decode. On this head: |
|
Thanks @jschmied. All four are answered: the CHANGELOG line, both tools and the ABBA numbers, the M5 refusal by |
|
/atc exchange b54e2fe8fc759cc36fc4ddb5877d1ec216b3dc32abae3000e190ac3b3de659e5 |
…shhart#1762) and add+norm under 1 %, direct load for Gemma 4 and Qwen 3.5 (ashhart#2282), Nemotron's done, q27 Metal pages (ashhart#2283)
…shhart#1762) and add+norm under 1 %, direct load for Gemma 4 and Qwen 3.5 (ashhart#2282), Nemotron's done, q27 Metal pages (ashhart#2283)
|
Our cells on this head (
It's in the landing queue now. |
Qwen3.8-27B on Metal takes its keys and values from pages of the core pool, behind
TF_QWEN27_METAL_KV_PAGES=1. It is off by default. This is the 27B step of #1293.What changes
metal kv pages, shared step: the head-major page row (tf_paged_row), the page tensor (core/kv_page_tensor.h) and the compile-time twin source edits (core/source_edit.zig) move intokernels/metal/core. Nemotron and Qwen 3.5 are rewired to them, with the same kernels and bits.qwen27 metal: paged twins of the 7 K/V kernels, derived frommain's sources throughsource_edit. Cache and binding carry the page table, and admission goes throughmetal_admit.pages(kv_pool.plan). Snapshot spans and the digest follow the pages.Pagesthrough a thin grow/keep, to be folded in once metal nemotron: TF_KV_SHARE keeps prompt states as core pool pages (stacked on #1837) #1850 lands.tf-qwen27-pages-resume: on the synthetic model, a kept state is saved through pages, its slot overwritten, then restored and decoded; then the slot moves to 1 and back. The restored, moved and fresh digests (KV rows included) equalmain's.Checks
70ae7fac:main, flag off and flag on, alone and with 2 streams.tf-kernel-contract --only qwen27passes 24 kernels at gates 1-4 with 0 fails, and 2/2 controls are red.tf-kernel-contract --only nemotrongives the same SUMMARY asmain.zig build testpasses 691/691 steps.zig build test, the no-GPU CI set,git diff --checkandzig fmt --checkpass.main.