Skip to content

persisted states bind to the resolved profile values - #2207

Merged
ashhart merged 2 commits into
mainfrom
lead/profile-disk-identity
Nov 5, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/profile-disk-identity

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner

fix(cache): bind persisted states to resolved profile values

Refs #2131. Native CUDA and the four Metal persistence owners share a helper that hashes every applicable arithmetic, experimental or debug profile entry. Environment values override entry defaults; booleans/counts are canonicalized, so an unset boolean and explicit 0 keep the same identity. Identical and out-of-scope entries contribute nothing. Generic CUDA uses its registered family name, and Qwen Metal distinguishes dense and routed configurations.

The failing-before recording-driver test reaches the actual CUDA identity: unset and 1 incorrectly share a key. After the fix they differ, unset=0, the same-key persisted-index reopen hits and the changed-key reopen misses. Main has no arithmetic row, so the test deliberately supplies a fake Entry; this does not qualify TF_QWEN_REQUEST_STARTS or another real arithmetic switch. Scope/default/all-entry controls and actual CUDA/Metal consumer compilation are included.

The audit table is docs/recipes/persisted-profile-keys.md. Remaining complete executable/cubin/checkpoint/variant bindings belong to the separate #2163 follow-up; this commit closes the registered-profile omission. The first long prompt under a changed relevant setting prefills again. No kernel, state bytes, admission or serving default changes.

Host checks pass, with no new lean findings. Resume-versus-fresh on a real device and speed are unchecked: no GPU or model ran.

Hash every applicable non-identical profile entry at the native disk
identity boundary, with environment-first defaults and framed canonical
values. Ignore identical and out-of-scope rows. Bind generic CUDA to its
registered family and distinguish dense and routed Qwen on Metal.

Use the same helper from CUDA and all four Metal persistence owners.
Changing a relevant setting creates a fresh namespace while unset and
explicit-zero booleans retain the same key. Preserve state bytes and
matching rules, with no new runtime option or inference arithmetic change.

A recording-driver regression reaches actual CUDA identityOf, then proves
a same-key reopen hit and changed-key persisted-index miss. It uses an
explicit fake arithmetic row because main registers none yet. Add scope,
class, all-entry and resolved-default controls plus actual host consumer
compilation, and document the remaining persistence audit gaps separately.

Refs #2131.
@ashhart
ashhart force-pushed the lead/profile-disk-identity branch from 5d80fce to a928650 Compare November 5, 2026 06:45
@ashhart
ashhart merged commit 5511462 into main Nov 5, 2026
5 of 7 checks passed
ashhart added a commit that referenced this pull request Nov 7, 2026
…prefetch line, one #2011 line, #2207's line, blank lines between bullets)
ashhart added a commit that referenced this pull request Nov 7, 2026
kelchm pushed a commit to kelchm/TensorFold that referenced this pull request Nov 7, 2026
…te on disk (ashhart#1411)

A backport of ashhart#1411 (head d903d85, on main a757420) to this stack (f350cd3 + 0001-0108).
With --learn-conversations, GLM-5.3-Flash's kept prompt states go to the rows store on disk, every rank's part,
so a conversation resumes from disk after its RAM copy is evicted or the server restarts. Off by default and
unchanged when the flag is unset.

- cuda_disk_image: a kept state's disk image on one rank: the words (format, position, head rows, ring bases,
  KDA copy bits), the KDA prefix, each DSA layer's latent rows, scales and pooled keys by position, the rings
  and pools in progress, the head's caches at a whole verify window, then the tail. Copies run a page of the
  lease at a time: 0015's device pages, then its pinned host pages.
- cuda_disk_ranks + cuda_follow's disk step: rank 0's engine thread leases, fills, reads and seals each rank's
  copy through the follow link. The store's image is rank 0's image followed by each other rank's prefix; the
  rest is the same bytes on every rank, checked at start by the identity probe.
- cuda_snapshots: blankAs/seal. A disk read's blank state is refused by restore until its seal checks the
  words (head rows within the verify window, ring bases that hold the state's rows, copy bits).
- native: the disk store attaches for GLM; --spill-gib and --checkpoint-slots are refused for GLM, as
  --learn-conversations alone keeps its states.
- rows: a pool that reuses spare storage reads a disk state into it; a trimming pool stays within its budget.

On this stack:
- The lease is 0015's two tiers. A host page copies with a memcpy, a device page with cuMemcpyDtoH/HtoD.
- Beside DFlash2 a kept state's head holds no rows, and the image carries no drafter ring. A state read from
  disk restores with DFlash2 restarted at the mark, as TF_GLM_SNAP_DRAFTER=0 does for a RAM state.
- Not carried over from upstream: TF_GLM_KV_SHARE's refusal (no such switch here) and ashhart#2207's identity profile.
- Tests take window_rows 16 (0039) and index_ring 8,192 (0094), and the round trip runs on a device-only pool
  and on one whose lease runs onto host pages.

Original commits by Robert Wojciechowski (GitHub @wojo, X @rwojo) in ashhart#1411.

Origin: MiaAI-Lab/GLM-5.3-Flash-DGX-Sparks-1104@13f2464 patches/engine 0109-glm-cuda-learn-conversations-keeps-every-rank-s-part.patch sha256:35a316d41dcec7590f89c6128e51286a5653d60865ce54ea3b256aa5379371d2
@ashhart
ashhart deleted the lead/profile-disk-identity 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