Skip to content

Persistence: the key gaps #2163 leaves, for every family (closes #2131) - #2287

Merged
ashhart merged 13 commits into
mainfrom
lead/persistence-gaps
Nov 9, 2026
Merged

ashhart merged 13 commits into
mainfrom
lead/persistence-gaps

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

This is the rest of #2131, after #2163 bound saved prompt states to the serving binary and checkpoint stamps. It audits every family that saves prompt states to disk and fixes what #2163 left.

What each owner's key covers is the table in docs/recipes/persisted-serving-keys.md. It has eight family and backend combinations: Nemotron, dense Qwen, GLM and Flash Next on Metal, and Nemotron, dense Qwen, Qwen MoE and Flash Next on CUDA. Other families have no cross-process disk tier.

The gaps this closes

  • Resolved runtime policy. The arithmetic and loading choices a run actually used are bound to the state, not the flags as set.
    • GLM keys whether the MTP head's prompt eh_proj ran on the tile kernel as the load built it.
    • Flash Next on Metal keys its resolved branches, including the DeltaNet window kernels, but not the serial-encoder choice, which only orders the same launches.
    • Qwen on Metal keys its loaded ANE columns and prompt chunk height, not buffer sizes.
  • Indexed shard paths. Every weight-map path the loader follows, including subfolders, goes into the checkpoint stamp, not only top-level files. A shard the index names but the folder lacks is refused as IndexedShardMissing, as the loaders already refuse it.
  • External loaded assets. These are inputs read from outside the checkpoint's own tensors that the computation consumes: the rotary table the CUDA Qwen target uses, a Flash Next weight pack outside the checkpoint folder, and loaded metadata such as a supplied reference.

A stale state now misses safely when any of these change. A fresh save's bytes and snapshot layouts don't change. Host tests cover each owner with a gap: a state changed in just that input misses, and a matching one still hits.

What users will see

  • Upgrading starts every kept conversation state and learned imprint cold once, because the keys moved. This applies to Nemotron, Qwen, GLM and Flash Next on Metal, and to Qwen on CUDA.
  • Changing the prompt chunk height starts the GLM and Qwen Metal stores cold. GLM's prompt windows and chunks sum in different orders (Proposal: restore single-Mac GLM-5.3-Flash on the M3 Ultra #743), and Qwen's may too.
  • GLM_EHPROJ_NAX now accepts only 0 or 1. Other text, which main read as on, is refused at start by name. Blank or unset still means the tile kernel.

Still open before this leaves draft

  • Flash Next on CUDA and Nemotron now key what their prompt passes resolved: Flash Next's chunk heights, DeltaNet and hyper-connection forms, read-out and fact rows, its lane's half-tile threshold and the SM count its BF16 prompt tile is weighed against; Nemotron's --precision checkpoint math, expert ranks, a ModelOpt lane's half-tile threshold and, with a captured set, the attention variant its --context picks. What stays unkeyed, and why, is in the recipe. Host tests miss on each changed value and hit on the same, and three source checks pin Nemotron's wiring.
  • Device runs. Restart runs with exact resumed-and-fresh token arrays on a Mac and a GB10. These include whether Qwen's chunk height changes its state.
  • gdn_pipe / gdn_kept. These stay in Flash Next Metal's key until a device bits run shows the two DeltaNet kernels write the same state.

@ashhart
ashhart force-pushed the lead/persistence-gaps branch 3 times, most recently from ab312b5 to e308a7d Compare November 9, 2026 07:02
ashhart added a commit that referenced this pull request Nov 9, 2026
…ed for

Review of #2287. GLM's key read GLM_EHPROJ_NAX itself and still said "tile"
when the tile pipeline failed to build and eh_proj served on the scalar kernel.
The setting is now a row of platform/environment.zig's table (0 or 1, refused
otherwise at startup), read once where wide.zig builds the pipeline; 0 builds
none. The prompt pass no longer reads the environment: bf16Nax serves on the
scalar kernel whenever that pipeline is absent, and the key takes ehTile, true
only with a prompt path, a bf16 head and the built pipeline.

Flash Next's key drops `serial`: it only picks a serial encoder over barriers
between the same launches, and the host flips it per call. gdn_pipe and
gdn_kept stay: they choose the kernel that writes the DeltaNet state and conv
rows a snapshot copies. Qwen Metal's key drops frame.capacity, which only sizes
buffers and bounds a pass's rows, and keeps back.chunk; a different chunk
height starts the Qwen and GLM stores cold, as the recipe now says.

An indexed shard missing from the folder is refused as IndexedShardMissing
(the loaders already refuse it). Nemotron Metal's identity no longer hashes
config and index bytes twice. The rewrite tests move the rewritten shard's
mtime a second on instead of sleeping 5 ms first.
@ashhart
ashhart force-pushed the lead/persistence-gaps branch from e308a7d to 30064ad Compare November 9, 2026 11:52
ashhart added a commit that referenced this pull request Nov 9, 2026
…ed for

Review of #2287. GLM's key read GLM_EHPROJ_NAX itself and still said "tile"
when the tile pipeline failed to build and eh_proj served on the scalar kernel.
The setting is now a row of platform/environment.zig's table (0 or 1, refused
otherwise at startup), read once where wide.zig builds the pipeline; 0 builds
none. The prompt pass no longer reads the environment: bf16Nax serves on the
scalar kernel whenever that pipeline is absent, and the key takes ehTile, true
only with a prompt path, a bf16 head and the built pipeline.

Flash Next's key drops `serial`: it only picks a serial encoder over barriers
between the same launches, and the host flips it per call. gdn_pipe and
gdn_kept stay: they choose the kernel that writes the DeltaNet state and conv
rows a snapshot copies. Qwen Metal's key drops frame.capacity, which only sizes
buffers and bounds a pass's rows, and keeps back.chunk; a different chunk
height starts the Qwen and GLM stores cold, as the recipe now says.

An indexed shard missing from the folder is refused as IndexedShardMissing
(the loaders already refuse it). Nemotron Metal's identity no longer hashes
config and index bytes twice. The rewrite tests move the rewritten shard's
mtime a second on instead of sleeping 5 ms first.
ashhart added a commit that referenced this pull request Nov 9, 2026
…ses resolved

Review of #2287 asked why these two owners add no policy words. Kept states
come only from prompt passes, so the audit followed every load-time choice
to the kernel or layout that writes one.

Flash Next on CUDA now keys its solo and busy chunk heights, the DeltaNet,
read-out, hyper-connection and in-pass mark forms, the NVFP4 prompt-tile
threshold, the K32 and BF16 prompt tiles, the experts' decode warps and
resident grids, and whether a captured set runs and which entries run on
our glue beside it. The five per-call switches are read once in
Kernels.load (Forms), and the pass and the key both read that.

Nemotron on CUDA keys --precision checkpoint's math, the expert ranks of
TF_NEMOTRON_WORLD, a ModelOpt checkpoint's NVFP4 decode warps and the
experts' resident grids. Nemotron on Metal keys TF_COOP_SPLIT as the
backend resolved it at load and, with the split on, the scratch rows a
prompt chunk's partials must fit.

Each goes through persistence_policy.extend under its own domain. Snapshot
payloads and layouts are unchanged; only the namespace key moves.
@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Restart check on an M3 Ultra, this head 30064ad61c, Qwen3.8-27B MLX 4-bit, a 4.9k-token conversation at T=0:

  • Resume after a restart: with --learn-conversations, turn 1 kept, server closed and restarted, turn 2 read 4,867 of 4,894 prompt tokens from disk. Its reply equals a fresh server's with no cache (a1b4263206ffcec5 both).
  • A changed key starts cold: the same store under TF_PROMPT_ROWS=256 opened another namespace and started cold (0 cached), with the same reply.

The same check on a GB10 (Nemotron NVFP4, with TF_QMMF_HALF_BELOW=0 as the changed key) is queued.

@ashhart
ashhart marked this pull request as ready for review November 9, 2026 12:45
@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

The same restart check on a GB10, this head 30064ad61c, Nemotron NVFP4 (a ModelOpt checkpoint):

  • Resume after a restart: turn 2 read 4,760 of 4,919 prompt tokens from disk. Its reply equals a fresh server's (fd19ba4d415eb3dc both).
  • A changed key starts cold: under TF_QMMF_HALF_BELOW=0, the same store opened another namespace and started cold, with the same reply.

Both platforms pass, so this is out of draft and in our landing queue.

Key resolved Metal policies and CUDA Qwen rotary inputs independently of
startup probes. Include Flash Next's opened pack stamps and loaded metadata
in its namespace. Keep snapshot payloads and layouts unchanged, and cover
stale misses and matching disk reads with host regressions.

Refs #2131. Stacked on #2163.
Stamp validated weight-map paths, including nested shards and files with
other suffixes, while retaining auxiliary top-level safetensors. Use the
same reader for Nemotron on Metal. Share the existing index validation
bodies across modules without changing filename admission.

Cover all eight native disk owners with same-probe stale misses and
matching reads of planted conversation states.

Refs #2131. Stacked on #2163.
Exercise nested safetensors paths admitted by every audited family. The
shared reader also retains all other indexed names its loader admits.

Refs #2131.
…ed for

Review of #2287. GLM's key read GLM_EHPROJ_NAX itself and still said "tile"
when the tile pipeline failed to build and eh_proj served on the scalar kernel.
The setting is now a row of platform/environment.zig's table (0 or 1, refused
otherwise at startup), read once where wide.zig builds the pipeline; 0 builds
none. The prompt pass no longer reads the environment: bf16Nax serves on the
scalar kernel whenever that pipeline is absent, and the key takes ehTile, true
only with a prompt path, a bf16 head and the built pipeline.

Flash Next's key drops `serial`: it only picks a serial encoder over barriers
between the same launches, and the host flips it per call. gdn_pipe and
gdn_kept stay: they choose the kernel that writes the DeltaNet state and conv
rows a snapshot copies. Qwen Metal's key drops frame.capacity, which only sizes
buffers and bounds a pass's rows, and keeps back.chunk; a different chunk
height starts the Qwen and GLM stores cold, as the recipe now says.

An indexed shard missing from the folder is refused as IndexedShardMissing
(the loaders already refuse it). Nemotron Metal's identity no longer hashes
config and index bytes twice. The rewrite tests move the rewritten shard's
mtime a second on instead of sleeping 5 ms first.
…ses resolved

Review of #2287 asked why these two owners add no policy words. Kept states
come only from prompt passes, so the audit followed every load-time choice
to the kernel or layout that writes one.

Flash Next on CUDA now keys its solo and busy chunk heights, the DeltaNet,
read-out, hyper-connection and in-pass mark forms, the NVFP4 prompt-tile
threshold, the K32 and BF16 prompt tiles, the experts' decode warps and
resident grids, and whether a captured set runs and which entries run on
our glue beside it. The five per-call switches are read once in
Kernels.load (Forms), and the pass and the key both read that.

Nemotron on CUDA keys --precision checkpoint's math, the expert ranks of
TF_NEMOTRON_WORLD, a ModelOpt checkpoint's NVFP4 decode warps and the
experts' resident grids. Nemotron on Metal keys TF_COOP_SPLIT as the
backend resolved it at load and, with the split on, the scratch rows a
prompt chunk's partials must fit.

Each goes through persistence_policy.extend under its own domain. Snapshot
payloads and layouts are unchanged; only the namespace key moves.
…isk states

TF_QMMF_HALF_BELOW is resolved into qmmf's Lane at load. A pass of 16 rows
or fewer with BF16 or MXFP8 weights then takes the 32-column tile instead
of the 64-column one. Flash Next reaches it through the shared expert's
nativeMatmul, and Nemotron through a ModelOpt checkpoint's lane, so a short
prompt chunk saved under one threshold could resume under another. The
startup probe's mark sits in a longer pass and never exercises this form.

Both keys now carry the threshold as the lane loaded it. Flash Next also
hashes the SM count its BF16 prompt tile is weighed against beside the
experts' grids, which already moved with it.
With a captured set, --context decides which _chunk and _merge variant runs:
the smallest whose NCH covers the context's chunks. The captured merge's
reduction over NCH chunks cannot be shown to ignore those past a row, so a
state saved under one context could resume under another variant.

The key now carries NCH while a captured set runs. Our own merge reads only
a row's chunks and uses NCH as a stride, so without a set the context stays
out of the key.
The policy tests call withPolicy directly, so the call sites that build the
keys went untested: the CUDA disk identity could return its legacy id, the
Metal learned identity its bare hash, or the backend could keep a constant
in place of TF_COOP_SPLIT as the forward pass resolves it, and every test
stayed green. None of these runs on a host without a device.

test-cuda-persistence-source-host now reads the three function bodies,
without whitespace or line comments, and requires each call.
…which paging is keyed

Flash Next's TF_FLASHNEXT_KV_PAGES and _KV_PAGES_ALL are keyed through the
profile rows; only the page-placement test switch is not. The CUDA rows and
paragraph also name the lane's half-tile threshold, the BF16 prompt tile's
SM count and Nemotron's captured attention variant.
…tead of setting it

Zig 0.17's std panics in dirSetTimestamps on Windows, so the rewrite there only checks that the write time moved,
and skips the test when it didn't.
@ashhart
ashhart force-pushed the lead/persistence-gaps branch from 383b731 to acc89a3 Compare November 9, 2026 19:49
@ashhart
ashhart merged commit a61b550 into main Nov 9, 2026
1 of 12 checks passed
ashhart added a commit that referenced this pull request Nov 9, 2026
…ed for

Review of #2287. GLM's key read GLM_EHPROJ_NAX itself and still said "tile"
when the tile pipeline failed to build and eh_proj served on the scalar kernel.
The setting is now a row of platform/environment.zig's table (0 or 1, refused
otherwise at startup), read once where wide.zig builds the pipeline; 0 builds
none. The prompt pass no longer reads the environment: bf16Nax serves on the
scalar kernel whenever that pipeline is absent, and the key takes ehTile, true
only with a prompt path, a bf16 head and the built pipeline.

Flash Next's key drops `serial`: it only picks a serial encoder over barriers
between the same launches, and the host flips it per call. gdn_pipe and
gdn_kept stay: they choose the kernel that writes the DeltaNet state and conv
rows a snapshot copies. Qwen Metal's key drops frame.capacity, which only sizes
buffers and bounds a pass's rows, and keeps back.chunk; a different chunk
height starts the Qwen and GLM stores cold, as the recipe now says.

An indexed shard missing from the folder is refused as IndexedShardMissing
(the loaders already refuse it). Nemotron Metal's identity no longer hashes
config and index bytes twice. The rewrite tests move the rewritten shard's
mtime a second on instead of sleeping 5 ms first.
ashhart added a commit that referenced this pull request Nov 9, 2026
…ses resolved

Review of #2287 asked why these two owners add no policy words. Kept states
come only from prompt passes, so the audit followed every load-time choice
to the kernel or layout that writes one.

Flash Next on CUDA now keys its solo and busy chunk heights, the DeltaNet,
read-out, hyper-connection and in-pass mark forms, the NVFP4 prompt-tile
threshold, the K32 and BF16 prompt tiles, the experts' decode warps and
resident grids, and whether a captured set runs and which entries run on
our glue beside it. The five per-call switches are read once in
Kernels.load (Forms), and the pass and the key both read that.

Nemotron on CUDA keys --precision checkpoint's math, the expert ranks of
TF_NEMOTRON_WORLD, a ModelOpt checkpoint's NVFP4 decode warps and the
experts' resident grids. Nemotron on Metal keys TF_COOP_SPLIT as the
backend resolved it at load and, with the split on, the scratch rows a
prompt chunk's partials must fit.

Each goes through persistence_policy.extend under its own domain. Snapshot
payloads and layouts are unchanged; only the namespace key moves.
ashhart added a commit to mrv777/TensorFold that referenced this pull request Nov 9, 2026
ashhart added a commit that referenced this pull request Nov 9, 2026
ashhart added a commit that referenced this pull request Nov 10, 2026
Figures corrected to the PRs' measured ones (#2699 head runs, #2509,
#2633, #2436, #2644, #2593, #2430, #2568), scope fixed (#2253, #2287,
#2511, #2569, #2337, #2627, #2351, #2626), unsourced figures dropped
(#2181, #2606, #2257's pricing clauses), the shipped #2176, #2565,
#2548 and gfx12 silu entries and the first #2625 copy removed, and
the #2568 and #2352 entries unwrapped to one line each.
ashhart added a commit that referenced this pull request Nov 10, 2026
qwen35_draft.cu gained the opt-in DSpine draft kernels (#2633),
flashnext_hc.cu shares sum_rn and rms_scale with the same SASS
(#2666, #2684), and flashnext/cuda_batch.zig keys disk states by the
resolved prompt passes (#2287). test-qwen-serving-host and
test-gradient-serving fail on main until the pins follow.
ashhart added a commit that referenced this pull request Nov 10, 2026
qwen35_draft.cu gained the opt-in DSpine draft kernels (#2633),
flashnext_hc.cu shares sum_rn and rms_scale with the same SASS
(#2666, #2684), and flashnext/cuda_batch.zig keys disk states by the
resolved prompt passes (#2287). test-qwen-serving-host and
test-gradient-serving fail on main until the pins follow.
ashhart added a commit that referenced this pull request Nov 10, 2026
qwen35_draft.cu gained the opt-in DSpine draft kernels (#2633),
flashnext_hc.cu shares sum_rn and rms_scale with the same SASS
(#2666, #2684), and flashnext/cuda_batch.zig keys disk states by the
resolved prompt passes (#2287). test-qwen-serving-host and
test-gradient-serving fail on main until the pins follow.
@ashhart
ashhart deleted the lead/persistence-gaps branch November 10, 2026 16:34
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.

1 participant