server: retry disk KV lookup with token text - #943
Open
JordiPosthumus wants to merge 1 commit into
Open
Conversation
JordiPosthumus
marked this pull request as draft
September 2, 2026 03:26
JordiPosthumus
marked this pull request as ready for review
September 3, 2026 10:59
JordiPosthumus
force-pushed
the
codex/pr-token-text-cache-lookup
branch
from
September 3, 2026 10:59
9079d2f to
2fbb18d
Compare
JordiPosthumus
force-pushed
the
codex/pr-token-text-cache-lookup
branch
from
September 4, 2026 18:06
2fbb18d to
39929a2
Compare
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.
Summary
Retry a rendered-text disk-cache miss with the decoded text of the request's
already-tokenized prompt.
Why
Continued checkpoints are keyed by token text. A client can replay identical
tokens using a byte spelling that the tokenizer canonicalizes. Looking up only
the original request bytes misses the valid checkpoint and repeats prefill.
The existing raw lookup remains first. Only after a miss, DS4 decodes the
already-tokenized prompt and retries through the same checkpoint loader and
validation. The fallback therefore changes candidate discovery, not checkpoint
acceptance.
Compatibility
No cache format, admission, image handling, sampling, launcher or default
change. Existing cache files remain usable. Live rewind is not enabled.
Validation
Rebuilt as one commit directly on main
b0a147a7fba6d1a104d047d5a140e9bb4bfc13cd. New tests cover raw-hitshort-circuit, canonical fallback and output propagation, disabled cache,
canonical-equals-raw, and raw/canonical prefix lookup. The existing loader
continues to enforce model, payload and image eligibility; this patch does not
replace those checks. A dedicated token-decoder failure-injection test is not
included.
Apple M3 Ultra, Metal default build; CPU is compile/link portability only:
All commands passed on 2026-09-04. Earlier C ASan+UBSan server checks passed.
In a fresh-process M3 Ultra/Metal run, Vision-Exp MXFP4 used as a text model
recovered 32,768 cached tokens and evaluated only a 3,664-token suffix. An
unrelated-prefix control explicitly stayed cold. The server invocation was:
This is focused validation, not a full aggregate model suite.
Merge coordination: #961 adds image-conditioned candidate filtering at the same
lookup site. If either lands first, retain both the raw-first/canonical fallback
and the image filter when refreshing the other.