Repository navigation
metal nemotron: keys and values in the core KV pool's pages (TF_NEMOTRON_METAL_KV_PAGES) - #1537
Conversation
|
@jschmied — M5 Max results for this PR, and for the tensor-form and gate-5 half of #1535. Commit provenance (the record patch is pushed to my fork for review; no comment or pull request was created anywhere):
Review branch — Machine: Apple M5 Max (Mac17,7), 40 GPU cores, 128 GiB, macOS 27.2 build 26B5101f, Xcode 27.1, Zig 0.17.0, How this is classified
Kernels — unmodified head, tensor form
Read Worst gate-3 bound use across the attention entries is 0.378 ( The one known finding, named — not Kernel Gate 5 for 9–16, and what "1024" measuresBoth record files stop at 8 tiles, so the head runs 52 Nemotron launch checks and never compiles a 288–512-thread
Same for the eight paged twins. Where the numbers come from: gate 5 builds the pipeline from the loader's source M1/M2 stays unmeasured. ServingA = main
Performance — measured, not boundedA "block" is one server start plus one timing run; each cell is the harness median over 2 repetitions of the
Block spread over the session was 1.68× (TTFT 2k), 1.27× (TTFT 8k), 1.32–1.34× (decode), 1.26× (4-stream) — Two things I will not claim. No parity and no "no regression below 3 %": with 4 pairs and a drifting session, Memory: three different numbersC's extra memory is reserved arena capacity — Inherited, unchangedSame line on Remaining limitations
m5max-pr1537-c246e6d9-gate5-records.patch - the same commit as the review branch The archive carries |
…ials Main's attn_partial_9 ... _16 and their paged twins launch 288 to 512 threads a group. They had no gate 5 record, so gate 5 neither compiled nor checked them on any chip. - Register both sets at 32*n threads and 2048*n threadgroup bytes. - Xcode's translator cannot build this family for M1/M2 (air-tt fails for every partial, 1 to 16), so MetalLaunch gains unbuildable: such a launch is unmeasured on M1/M2 rather than shown to fit. Absolute family limits still apply, and the offline run prints SKIP for each one instead of FAIL. - Log which attention form compiled, so a run records tensor ops against the SIMD rewrite (the M5 Max compiles the sources as written). Base: c246e6d (PR ashhart#1537 head). Pushed as review support for ashhart#1537; not proposed as a merge commit on its own.
|
Thanks @swbiggart, this is a thorough run. I've taken your records commit into the PR as Agreed on the performance reading: no bound is claimed, and the 0.88 GiB is reserved arena capacity, not a saving. The M1/M2 large-partial limits stay listed as open. |
… main's through shuffled pages, a swapped page caught
…ernels at every shape and page edge, six planted controls, their launches
…V_PAGES Decode, MTP trees, GPU rounds and prefill bind the paged twins and the stream lane table; a stream leases and covers its pages when it opens and returns them when it closes. Snapshots copy from the pages, and the census is logged once no stream is open. Off by default.
With TF_NEMOTRON_METAL_KV_PAGES=1 the load plans streams and pages beside the model, at most one arena buffer, and attaches them to the backend.
…oat64 attn_partial_1..16 with attn_merge, the tree partial with tf_tree_tail and tf_tree_merge, tf_attention_nax, tf_kv_write, kv_put and tf_kv_compact, in the form this GPU compiles, each with a planted control (ashhart#1535).
partial_1..8, the merges, the tree tail, the glue and the four prompt variants; partial_9..16 wait for a run on a GPU with tensor units (ashhart#1535).
…ials Main's attn_partial_9 ... _16 and their paged twins launch 288 to 512 threads a group. They had no gate 5 record, so gate 5 neither compiled nor checked them on any chip. - Register both sets at 32*n threads and 2048*n threadgroup bytes. - Xcode's translator cannot build this family for M1/M2 (air-tt fails for every partial, 1 to 16), so MetalLaunch gains unbuildable: such a launch is unmeasured on M1/M2 rather than shown to fit. Absolute family limits still apply, and the offline run prints SKIP for each one instead of FAIL. - Log which attention form compiled, so a run records tensor ops against the SIMD rewrite (the M5 Max compiles the sources as written). Base: c246e6d (PR ashhart#1537 head). Pushed as review support for ashhart#1537; not proposed as a merge commit on its own.
311ff37 to
12b4a98
Compare
…ials Main's attn_partial_9 ... _16 and their paged twins launch 288 to 512 threads a group. They had no gate 5 record, so gate 5 neither compiled nor checked them on any chip. - Register both sets at 32*n threads and 2048*n threadgroup bytes. - Xcode's translator cannot build this family for M1/M2 (air-tt fails for every partial, 1 to 16), so MetalLaunch gains unbuildable: such a launch is unmeasured on M1/M2 rather than shown to fit. Absolute family limits still apply, and the offline run prints SKIP for each one instead of FAIL. - Log which attention form compiled, so a run records tensor ops against the SIMD rewrite (the M5 Max compiles the sources as written). Base: c246e6d (PR #1537 head). Pushed as review support for #1537; not proposed as a merge commit on its own.
|
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. |
…and Nemotron's Metal paging The switch registry grows by four rows (ashhart#1660's next group, all measured identical): TENSORFOLD_DORY_KV_PAGES (opt-in, ashhart#1284), TENSORFOLD_GEMMA4_KV_PAGES and TENSORFOLD_SPARK25_KV_PAGES (default-on, exact 0 opts out, ashhart#1619, ashhart#1653), and TF_NEMOTRON_METAL_KV_PAGES, the first metal-backend row (exact 1, ashhart#1537). A new .not_zero syntax covers Dory's on-unless-0 reader; the 0-opt-out rows reuse report_values. The four readers go through the registry's environment-first helper, so an unset variable and every set value behave byte for byte as before.
…and Nemotron's Metal paging The switch registry grows by four rows (ashhart#1660's next group, all measured identical): TENSORFOLD_DORY_KV_PAGES (opt-in, ashhart#1284), TENSORFOLD_GEMMA4_KV_PAGES and TENSORFOLD_SPARK25_KV_PAGES (default-on, exact 0 opts out, ashhart#1619, ashhart#1653), and TF_NEMOTRON_METAL_KV_PAGES, the first metal-backend row (exact 1, ashhart#1537). A new .not_zero syntax covers Dory's on-unless-0 reader; the 0-opt-out rows reuse report_values. The four readers go through the registry's environment-first helper, so an unset variable and every set value behave byte for byte as before.
…and Nemotron's Metal paging The switch registry grows by four rows (ashhart#1660's next group, all measured identical): TENSORFOLD_DORY_KV_PAGES (opt-in, ashhart#1284), TENSORFOLD_GEMMA4_KV_PAGES and TENSORFOLD_SPARK25_KV_PAGES (default-on, exact 0 opts out, ashhart#1619, ashhart#1653), and TF_NEMOTRON_METAL_KV_PAGES, the first metal-backend row (exact 1, ashhart#1537). A new .not_zero syntax covers Dory's on-unless-0 reader; the 0-opt-out rows reuse report_values. The four readers go through the registry's environment-first helper, so an unset variable and every set value behave byte for byte as before.
…and Nemotron's Metal paging The switch registry grows by four rows (ashhart#1660's next group, all measured identical): TENSORFOLD_DORY_KV_PAGES (opt-in, ashhart#1284), TENSORFOLD_GEMMA4_KV_PAGES and TENSORFOLD_SPARK25_KV_PAGES (default-on, exact 0 opts out, ashhart#1619, ashhart#1653), and TF_NEMOTRON_METAL_KV_PAGES, the first metal-backend row (exact 1, ashhart#1537). A new .not_zero syntax covers Dory's on-unless-0 reader; the 0-opt-out rows reuse report_values. The four readers go through the registry's environment-first helper, so an unset variable and every set value behave byte for byte as before.
…and Nemotron's Metal paging The switch registry grows by four rows (ashhart#1660's next group, all measured identical): TENSORFOLD_DORY_KV_PAGES (opt-in, ashhart#1284), TENSORFOLD_GEMMA4_KV_PAGES and TENSORFOLD_SPARK25_KV_PAGES (default-on, exact 0 opts out, ashhart#1619, ashhart#1653), and TF_NEMOTRON_METAL_KV_PAGES, the first metal-backend row (exact 1, ashhart#1537). A new .not_zero syntax covers Dory's on-unless-0 reader; the 0-opt-out rows reuse report_values. The four readers go through the registry's environment-first helper, so an unset variable and every set value behave byte for byte as before.
…and Nemotron's Metal paging The switch registry grows by four rows (#1660's next group, all measured identical): TENSORFOLD_DORY_KV_PAGES (opt-in, #1284), TENSORFOLD_GEMMA4_KV_PAGES and TENSORFOLD_SPARK25_KV_PAGES (default-on, exact 0 opts out, #1619, #1653), and TF_NEMOTRON_METAL_KV_PAGES, the first metal-backend row (exact 1, #1537). A new .not_zero syntax covers Dory's on-unless-0 reader; the 0-opt-out rows reuse report_values. The four readers go through the registry's environment-first helper, so an unset variable and every set value behave byte for byte as before.
metal nemotron: keys and values in the core KV pool's pages (TF_NEMOTRON_METAL_KV_PAGES)
Step 3 of #1293. On by
TF_NEMOTRON_METAL_KV_PAGES=1and off by default. With the flag off, the only change is the added?pagedbranches; every existing.metaland.hfile is byte-unchanged.What
Kernels (
78b8206fa,f1bc04559): paged twins of the six Nemotron Metal kernels that read or write K/V, in Nemotron's own paged library.attn_mergereads no K/V and needs no twin.tf_kv_write: also covers the GPU-args path.tf_kv_compact: coverstree.compactandgpu_round's compact.kv_put: keep 0 and 1.attn_partial_1…_16: the causal and shared passes.tf_tree_tail.tf_attention_nax: n_n, n_t, t_n and t_t.attn_partial,tree_tailandattention_naxare derived from main's sources by count-checked comptime edits. Their tests compile them as the loaders do: the SIMD rewrite,TF_SIMD_LAYOUT, frags.Serving (
d33c9c73c,6ed6c5f8b):kv_putrun on the twins and the lane table.metal_admit.pages), with one arena buffer at most.Verification
All Metal runs are on an M3 Pro, which has no tensor units, so the kernels run in their SIMD-rewritten form.
Kernels:
--only 'nemotron paged': 6 pass gates 1–4, and all 6 controls go red.Served, Lightning MLX 4-bit, greedy, 64 tokens, prompts of 34 / 990 / 4,981 / 20,173 tokens, flag off and on:
Speed: ABBA ×2,
--parallel 4, 3 repetitions a run, medians.Checks (now including the #1535 commits):
lean_check0 new;zig fmt --checkclean;zig build testpasses on macOS (withtest-metal-kv-pages) and on Linux.Open
?pagedbranches.attn_partial_9…_16(288 to 512 threads) have no gate 5 records, the same as main's kernels (Metal Nemotron: the attention kernels have no kernel-contract entries (gates 1–5) #1535).#1535, SIMD half (
c246e6d9b): main's Nemotron Metal attention kernels are registered intests/contract/metal_nemotron_attention.zig. The split-softmax kernels run as the engine chains them and are checked in float64 againstcore.attention_ref, following Qwen4's parts-and-merge precedent.attn_partial_N+ merge for N = 1 … 16;tf_tree_tail+tf_tree_merge);tf_attention_nax(all four variants);kv_write,kv_put,kv_compact.nemotron_attention_records.zig): all exceptattn_partial_9…_16, which are left for your M5 run.--only nemotron --offline) has one failure,glm gather glm_rows_bf16_nax, and main at the base has the same one.Overlap: this shares
families/nemotron/kernels.zigandlayers.zigwith #1466 (@mrv777, two members a pass for wide M1 windows), and one file conflicts. I'll rebase onto whichever lands first.