Skip to content

nemotron metal: kv_pages grow/keep inline, and debug builds assert each pass's rows sit in the lane's pages - #1914

Merged
ashhart merged 2 commits into
ashhart:mainfrom
jschmied:metal-kv-grow-assert
Nov 2, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
jschmied:metal-kv-grow-assert

Conversation

@jschmied

@jschmied jschmied commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

The follow-up asked for in #1837, stacked on it: its first two commits are #1837's, and the new one is a64f0cdf4.

  • kv_pages.grow and kv_pages.keep are inline, so with TF_NEMOTRON_METAL_KV_PAGES off each call site is one null check.
  • kv_pages.holds asserts, in debug builds, that every K/V row the host sizes sits inside the lane's pages. It runs at kvWrite, the prompt's K/V put and snapshot restore, and where GPU rounds queue and land.

Checks (M3 Pro):

  • Gates: fmt, lean 0 new, 590/590 steps.

  • Debug build with the flag on and MTP rounds at n=1 and n=4: replies byte-equal to main, no assertion fired, over 412 and 349 queued rounds. With grow deliberately short, the assertion fires.

  • Flag off, against main 57186386d, two base, new, new, base runs at 2K and 8K prompts with 256 new tokens; all 48 replies byte-equal:

    ratio, new / base
    decode after 8K ×0.9993 (64.74 → 64.70 tok/s)
    decode after 2K ×1.0014
    TTFT and prefill within 0.03 %

@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied. Both M5 Ultra runs are green against main, with prompt tokens identical in all 20 rows. Flag off: decode flat at every prompt size (2K 233.7 -> 233.5, 64K 203.7 -> 202.2 tok/s, runs overlapping), which settles the 1% we saw on #1837 as noise. Flag on (TF_NEMOTRON_METAL_KV_PAGES=1): 2K 235.6 -> 234.3 and 64K 204.0 -> 202.7 tok/s, within noise. The rebase onto main after #1837 left just your commit, and it passes our gate. It lands shortly.

jschmied and others added 2 commits November 2, 2026 14:49
…s's rows sit in the lane's pages (ashhart#1293)

With TF_NEMOTRON_METAL_KV_PAGES off each call site is one null check. kv_pages.holds asserts in debug builds at every
K/V row write the host sizes (kvWrite, the prompt's kv put, snapshot restore) and where GPU rounds queue and land.
@ashhart
ashhart force-pushed the metal-kv-grow-assert branch from a64f0cd to dde8c9f Compare November 2, 2026 14:49
@ashhart
ashhart merged commit b963f32 into ashhart:main Nov 2, 2026
9 of 11 checks passed
@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

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