Repository navigation
Conversation
A context checkpoint captured the draft context with PARTIAL_ONLY, but a plain attention KV (the MTP head) has no partial state, so it returned the draft's WHOLE sequence KV: 246 MB of each 312 MB checkpoint at 118k tokens (measured on a live page: tgt 65.9 MB, dft 245-250 MB per checkpoint), up to n_ctx_checkpoints copies per slot in RAM and in every saved page. Saves of a mind built over many turns took 1.8-3.1 s (2.9 GB sidecar) against 0.7-0.9 s for the same tokens with few checkpoints, all on the server loop. - create_checkpoint skips the draft when its memory rolls back by trimming (COMMON_CONTEXT_SEQ_RM_TYPE_PART): slot.mem.seq_rm already trims the live draft KV to the checkpoint on resume; load_dft is a no-op for an empty capture. - SLOT_SAVE writes the draft's sequence KV once in a `.dft` sidecar (magic DRFT, the token count it covers); the size quote counts it without copying. - SLOT_RESTORE loads it when it matches the restored tokens, and otherwise clears the draft sequence: before, a restore left the previous occupant's draft KV at those positions (drafts from another mind; the target still verified them). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Author
|
CHANGES REQUESTED at 828e032, on Codex's two findings, which I agree are real. The core claim holds. Claim verified: skipping the draft in PART checkpoints is safe. How I checked, by reading
Still to fix (Codex's findings):
The measurements (save 2653/1829 → 1153/700 ms, restore 465 → 248 ms, RSS −3.4 GB, greedy continuation identical) are Fable's, on the M5 against 741b017. I didn't re-run them. Cormac (Claude Code, enrico) |
joelteply
added a commit
that referenced
this pull request
Oct 28, 2026
…d draft (Codex/Cormac on #79); needs a hybrid MTP GGUF to run Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…en whole, and its size is bounded by the file (Codex and Cormac on #79) - The .dft header (version 2) carries an FNV-1a hash of the tokens it covers; a restore loads it only when the hash matches the restored tokens, so a torn or interrupted save can never pair one save's draft KV with another save's page of the same length. - The sidecar is written to .partial and renamed over, so a reader never sees a torn one. - A restore allocates the draft state only when n_state equals what the file holds past its header; a torn or hostile header asking for more is refused before any allocation. Checked: -fsyntax-only on server-context.cpp clean; a planted call error is reported (the check compiles this file). Not built or run: CI and Fable's M5 save/restore receipt cover it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
Author
joelteply
added a commit
that referenced
this pull request
Nov 16, 2026
…it (#79 on the shipping line, through #118's pipeline) (#130) * server: a page carries the draft's KV once; checkpoints stop copying it (#79 on the shipping line, through #118's page pipeline) A draft whose memory rolls back by trimming (plain attention KV: the MTP head) has nothing a checkpoint must hold; on restore slot.mem.seq_rm trims its live KV to the checkpoint (common_memory holds both contexts). Copying it made it 79% of every checkpoint (#79's M5 receipt: 246 MB at 118k tokens), up to n_ctx_checkpoints copies per slot in host RAM. Now: - create_checkpoint skips the draft's state when ctx_dft_seq_rm_type is PART; - a saved page carries the draft KV once, the `.dft` sidecar, riding #118's pipeline: copied on the loop into the job (counted in the size quote and in the page IO admission), written on the pool to .partial and renamed over (never torn; a stale .dft is removed when a page has none); - the header binds it to exactly the page's tokens (count + FNV-1a hash) and names the state's size; the pool reads it only when the file is exactly a header plus that state (never allocated from a claim); the loop applies it only when it covers exactly the restored tokens, else clears the draft sequence (never another occupant's KV at these positions): the draft then starts cold and the target still verifies every token. Receipts (qwen35-0.8b, --spec-type draft-mtp, M5, 2026-11-16): generate, save the page, erase the slot, restore it, continue at temperature 0: with the .dft sidecar the draft accepted 47 of 47; with it deleted before the restore, 43 of 59 (cold); the continuation text identical both ways. The same save on the shipping line without this change: .ckpt 43.9 MiB vs 38.5 MiB here with the draft carried once (3.3 MiB .dft) at ~1.7k tokens; the saving is ~2 KiB per token per checkpoint, so it grows with her context. 0 warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * server: the draft sidecar is bound to its page's computation and can never outlive an interrupted save (Codex's review of #130) - .dft v2 names an FNV-1a hash of the save's own .lora sidecar bytes (adapters + file revisions) beside the token hash; the restore applies the draft only when tokens AND computation match, else it drafts cold. - page_write removes the old .dft before publishing the page, and writes the new one last (temp + rename): an interruption anywhere leaves no draft or this save's, never an earlier save's of the same tokens. Receipt (qwen35-0.8b, draft-mtp, M5): clean save/erase/restore matched (no cold draft); the same .dft with its computation hash changed was refused ("no draft sidecar matching this page ... the draft starts cold"); a re-save rewrote it and the next restore matched again. 0 warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A context checkpoint captured the draft context with
PARTIAL_ONLY, but a plain attention KV (the MTP head) has no partial state, so it returned the draft's whole sequence KV in every checkpoint. On a live M5 page (Qwen3.6-35B-A3B + MTP, 118k tokens), each checkpoint was tgt 65.9 MB + dft 245-250 MB: up ton_ctx_checkpointscopies per slot in RAM and in every saved page. Saves of a mind built over many turns took 1.8-3.1 s on the server loop, freezing every stream.Change
create_checkpointskips the draft when its memory rolls back by trimming (COMMON_CONTEXT_SEQ_RM_TYPE_PART):slot.mem.seq_rmalready trims the live draft KV to the checkpoint on resume, andload_dftis a no-op for an empty capture.SLOT_SAVEwrites the draft's sequence KV once, in a.dftsidecar (magicDRFT, the token count it covers). The size quote counts it without copying.SLOT_RESTOREloads it when it matches the restored tokens, and otherwise clears the draft sequence. Before this, a restore left the previous occupant's draft KV at those positions, so the drafts came from another mind (the target still verified them).Measured
M5 Max, 2026-10-28 ~09:20Z, standalone server with the live flags (
-c 636928 --parallel 4, ctx-checkpoints 32, q4_0 KV, MTP draft). The same ~97.5k-token mind was built over 40 turns with prefix reuse, then saved twice, erased, restored and continued greedily. Script and output are on the M5 under~/.continuum/evidence/2026-10-28-page-save-repro/.Pages in the old format still restore: their checkpoints carry draft data, and
load_dftrestores it as before.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo