server: auto-discard reload-loop checkpoints (frontier-contradicted) - #1021
Open
nazerim wants to merge 1 commit into
Open
server: auto-discard reload-loop checkpoints (frontier-contradicted)#1021nazerim wants to merge 1 commit into
nazerim wants to merge 1 commit into
Conversation
A disk checkpoint whose stored tail contradicts fresh prompt tokenizations restores cleanly yet re-misses every following turn: the text-keyed tier loads the exact same file to the exact same frontier because its text key matches, while the memory tiers can never carry the session past that depth. Observed repeatedly in production on a fork carrying this same text tier (pinned miss clusters at common=118557 x43, 273833 x18, 451784, and 325177 - the last healing only when a manual turn-abort triggered the prefill-failed discard and the fallback chain walked to a lower valid file). Automate exactly that recovery: track the last disk-restored file and frontier per slot; a second consecutive restore of the same file at the same depth proves the tail is dead weight, so unlink it under kv_mu (same semantics as the prefill-failed discard beside it) and retry the load once, landing on the next candidate or a cold rebuild that rewrites fresh under the key. Any successful memory-tier continuation clears the tracker, so a legitimate later restore of the same correct file after real progress is never punished. The detection is provable-by-construction (same file + same frontier + same slot = the state cannot have advanced between restores) and the worst case is one wasted reload per poisoned file instead of an unbounded loop.
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.
Problem. The text-keyed disk tier validates text, not tokens. When a checkpoint's stored tail diverges from how future prompts re-tokenize the same bytes (BPE boundary variants across sampled thinking/DSML regions - the familiar two-variant equilibrium), the file restores fine, misses again next turn, and re-restores forever: pinned
reason=token-mismatchat the samecommon=on every following turn, growing re-prefill each time. Production evidence from my fork running this same tier: clusters at common=118557 (43 turns), 273833 (18), 451784, 325177 - the only cure observed was a manual turn-abort, which routes through the existing prefill-failed discard and lets the fallback chain land on a lower valid file.Fix. Same recovery, automated and provable: each slot remembers its last disk-restored (file, frontier). A second consecutive restore of the same file at the same depth means the session cannot have advanced between restores - the tail is dead weight by construction. Unlink it under
kv_mu(exactly the prefill-failed discard semantics already in this file), logreason=frontier-contradicted, and retry the load once: the refresh pass walks to the next candidate or a cold rebuild, which rewrites fresh under the key. Any successful memory-tier continuation clears the tracker, so legitimate re-restores of the same correct file after real progress are never punished; disagreement falls back to today's behavior verbatim.Blast radius: ~40 lines, one helper beside
kv_cache_discard_failed_disk_entry, one two-attempt loop at the existing call site, one clear on memory-tier success. No format, no key, no session-state changes; worst case is one wasted reload per poisoned file instead of an unbounded loop.Validation: optimized build clean (0 errors/0 warnings, M5 Max); ds4-server unit suite green on this head; the mechanism it automates (unlink + invalidate + fallback walk + fresh re-store) is the same one two production manual-abort recoveries exercised end-to-end, and the fork build with the automated detection self-healed two live loops on its first day (discarded at frontier 322155 -> adopted 321371 same second; 338690 -> 331026 same second).