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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
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