mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2228] Conversation cache falls back to 32,768-spaced checkpoints for a fast client: 13 re-reads of 6.8K-47K tokens (4-17 s TTFT) in 3.5 h while its prompts are pure appends #886
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#886
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jy02375437-max on GitHub (Oct 13, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2228
Summary. With a real remote agent client (Windows, OpenAI-style
/v1/chat/completionsthrough a reverse proxy, screenshots in the conversation), 0.1.43.1 repeatedly restores a coarse checkpoint instead of one at the last turn boundary, and re-reads everything since: 13 occurrences of 6.8K-47K fresh tokens (4-17 s TTFT) in 3.5 h, while the client's prompts are pure appends (verified: every earlier message is byte-identical between consecutive requests).Rig. RTX 4090D 48 GB, Windows 11, 128 GB RAM, NVMe; engine 0.1.43.1 release build; Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS native pack, all 24,576 experts resident;
--prefill auto:32768 --spec 4 --spec-min-p 0.70 --pcie-frac 0.35 --mtp <rt> --max-context 262144 --kv int8 --kv-resident 32768 --prompt-cache 12 --conversation-cache-mib 32768 --conversation-cache-slots 8 --vision --vram-reserve-mib 700 --embd-gguf(+--mtp-hnorm stream, measured neutral here). Vision runs on the CPU (strata-vision.exe, 16 threads).What the log shows. Every big read is preceded by a restore of a checkpoint (not the live state), and the restore points sit on an exact 32,768-token grid:
53533 + 32768·k = 86301 / 119069 / 151837 / 184605 / 217373 — every restore point is on that grid. Meanwhile the same conversation, a few requests earlier or later, reuses to 224,977 / 227,567 / 228,144 (i.e. per-turn positions), so the deep checkpoints do exist at other moments.
The client is not changing anything. I captured the raw request bodies (message-level sha1 per message). Consecutive requests of this client are pure appends — the first differing message index always equals the previous message count (e.g. 420->422->425->427->430->435), so every earlier message is byte-identical. One request in the middle of that run still fell back to 217,373 (~95.9% depth) and re-read 9,281 tokens (5.7 s).
What happens right before the fallback (one example, the 226654 request):
So a copy of the same conversation was parked at 225,122 tokens 13 ms earlier, the next request extends it by 1,532 tokens — and the engine restores a checkpoint 7,749 tokens behind the parked state (and after it, the conversation is left with 8 checkpoints instead of 12). The client sends requests every 2-6 s in bursts, so these copies churn (dropped/parked/superseded) fast.
Context that may matter: the conversation is screenshot-heavy (10 base64 images, one every few turns; the client is doing visual QA). The docs say a checkpoint "is used only when the prompt starts with exactly its tokens and pictures" (DETAILS.md, conversation cache section), so if picture validation can reject the newest turn-boundary checkpoints, the fallback would land on the deepest picture-clean one — but the exact 32768 spacing of the fallbacks looks more like the grid checkpoints ("every 16K prompt tokens") surviving while the turn-start checkpoints do not.
Question. Why would the turn-start checkpoints be unavailable for this conversation (so the engine falls back to the 16K/32K grid), and why would the newest parked copy's state not be used at the next request? Is the intent that a superseded copy keeps only the grid checkpoints, or that a fast supersede/park churn drops the per-turn ones? If it helps, I can re-run a smaller reproduction (a synthetic conversation with an image, extended a few turns, raw bodies attached) or instrument further.
Impact. This is our largest remaining TTFT cost for that client: ~2.5 minutes of re-reading across 13 requests in one 3.5 h session, each a 4-17 s stall that also blocks the single serving turn.
@jy02375437-max commented on GitHub (Oct 13, 2026):
Follow-up with live data from the same client (a long task has been running for the last hour through the same proxy). Three more things that the first report was missing.
1. The client runs several conversations that share the same head. All 37 captured requests from this IP have an identical system message and identical first user message (message-sha1
39a6680c…/44a216ef…), but they are different threads:So at any moment the cache holds several parked copies of the same conversation family with overlapping prefixes.
2. The fallback restores are the
(checkpoint)ones; the healthy restores are(live)or a recent turn-boundary(checkpoint). All restored points of the family sit on one grid: base 20,765 + 32,768·k (20,765 = the first turn boundary of thread 1; offsets mod 32768 = 20765 for 53,533 / 86,301 / 119,069 / 151,837 / 184,605 / 217,373). Reads from a grid point: 45,786 / 41,198 / 46,992 / 30,509 / 37,468 / 9,281 tokens (4-17 s). Reads from a live/turn-boundary restore: 55 / 68 / 136 / 198 / 228 / 457 / 466 tokens (1.4-2.3 s). A third case reuses only the root (20,777 reused + 18,729 read, 7.3 s) for the young sibling thread.3. Within each thread the prompts are pure appends (message-sha1: the first differing index always equals the previous message count). The history rewriting happens between threads, not inside one.
The question this narrows to: when a request's prefix matches several parked copies of the family, what picks the restore point? In the 12:14:06 case a copy of the same thread had just been parked at 225,122 (13 ms earlier) and the request extends it by 1,532 tokens, but the engine restored the grid checkpoint at 217,373 and re-read 9,281. Same shape at 151,837 / 184,605 / 217,373 for other turns. If the intent is "deepest valid checkpoint across all copies that match", something prefers the older/grid one — or the recent turn-boundary checkpoints of the other copies are invalidated when a sibling parks/updates (the log shows
dropped 1 superseded copy of this conversationimmediately before the 225122 park in that case).Impact unchanged: 21 restore events in this boot, the grid ones cost 4-17 s each and block the single serving turn. Happy to run any specific probing build or to capture more (the watcher is still running; bodies are on disk).
@jy02375437-max commented on GitHub (Oct 13, 2026):
Cross-reference for triage: PR #2094 ("immutable branching contexts", draft) and issue #1962 are about exactly the setup this report is about — several conversations sharing a prefix, parked copies, per-branch checkpoints. The production trace above is the pathology such work would have to avoid: a sibling copy's grid checkpoint winning over the requester's own deeper state, then a 6.8K-47K re-read (4-17 s) while the client's prompts are pure appends.
Not claiming #2094 fixes this — it is a draft (Windows validation listed as incomplete there) and the two are independent paths. Just noting the overlap for whoever picks this up; the raw evidence (engine log sequences, per-message sha1 comparisons, capture bodies) is in the thread above if it helps design the branch/checkpoint selection.
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks @jy02375437-max, the restore points and the message hashes narrow this a lot.
Where the 32,768 grid comes from. The periodic checkpoints are taken at chunk boundaries every
--prompt-cache-every(16384) tokens from where a read starts. With--prefill auto:32768the chunks are 32,768 tokens long, so a long read leaves one every 32,768 from its start. Your base 20,765 is the root (the first turn boundary).What the fallback means. In the 226,654 request, the engine first compared the prompt with its own live state (225,122) and the checkpoints it held, and nothing deeper than 217,373 matched. So the prompt and the held state differed somewhere in those last ~8K tokens, although your message bodies were byte-identical. A held state matches only if the prompt starts with its tokens and its pictures.
What we tested. Until now a picture was compared by a hash of its embedding floats, so we checked whether the image encoder gives the same bits for the same screenshot: fresh encoder processes, the same process twice, and 8 to 32 threads.
What changed in 0.1.44 (out now):
What would help: the engine log (
strata-*.log) around one fallback with 0.1.44. Look especially for anyconversation cache:line just before the restore. If no picture line appears, the difference is in the tokens themselves, and the log tells us at which position. Until then,--prefill auto:16384halves the grid spacing, so a fallback re-reads at most ~16K.@jy02375437-max commented on GitHub (Oct 13, 2026):
Installed 0.1.44 (release zip + tag) on the same box and replayed our exact production sequence (the 169 captured request bodies of one long task). The picture fix did not change this case, and the new diagnostics print nothing extra — which matches your note: the difference is in the tokens. This fallback is fully reproducible, so here is the window you asked for, plus one more data point.
The fallback (0.1.44, IQ3_S, RTX 4090D, Windows,
--prefill auto:32768 --prompt-cache 12 --kv-resident 32768, KV prefetch on):No picture line, no other line before the restore. The two requests' system message and 207-tool block are byte-identical (sha1-verified across the whole task), so the shared prefix is ~159K tokens; the prompt diverges only at the summary/recent-messages boundary.
What we cannot explain from our side: with
--prefill auto:32768the conversation should hold checkpoints at 32768-multiples of its read starts, i.e. 32,768 / 65,536 / 98,304 / 131,072 inside that identical block — a 131,072 restore would have left a ~37K re-read instead of 135,828. Instead the restore is exactly one chunk step (32,768).A probe that may point at the mechanism: on a fresh conversation the same engine restores 159,184 tokens here (the end-of-system-prompt root, 5.9 s read). After roughly twelve further requests of ordinary point-appends the root is gone and the compaction falls back to 32,768 (35.7 s read). With
--prompt-cache 48the root survives the same sequence and the restore is 159,184 again. So the root appears to be rotated out after about--prompt-cache-many new checkpoints. Is "the oldest (the root) is kept for good" still meant to hold under that churn?Repro:
bench/compaction_replay.py --fullin our checkout replays the captured bodies in order; the JSON with every restore isbench/compaction-replay-up0144-full.json. Happy to run any verbose or diagnostic build you want against this exact sequence.@Niko1221 commented on GitHub (Nov 5, 2026):
Thanks for taking the time to report this.
Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.