mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#1970
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 @shenmintao on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4420
Area
Engine (the server's conversation cache with
--batch)Desktop app, Terminal or source?
Source build in Docker (upstream v0.2.7 + local patches, see Strata version),
serve/server.pywithstrata --serve.What happened
Our voice assistant starts every request with the same 5,156-token prefix (system prompt + 18 tool definitions) and adds a
short question. Since 0.2.7, when its requests overlap another user's answer (
--batch 2), the cached prefix gets lost:the third overlapping request of our probe reads the whole prompt again (
prompt 5173 tokens = 0 reused + 5173 read in 4130 ms), where 0.2.6 on the same box borrows it (borrowed 5156 tokens from a parked conversationand5156 reused + 17 read in 323 ms). Requests sent alone are not affected: after the first one they reuse 5156 tokens on both versions.Expected: the shared prefix stays borrowable, as in 0.2.6.
Same box and config, alternating server starts. One of the three 0.2.7 starts ran without our
--pcie-frac 0.38(theengine's own split); everything else was identical.
Smallest steps or command that reproduce it
Server (the relevant arguments):
--serve --batch 2 --batch-mtp --mtp <dir> --spec 4 --spec-min-p 0.5 --kv q4_0 --max-context 524288 --conversation-cache-mib 1024 --conversation-cache-slots 6. One client process, every requesttemperature 0,reasoning_effort none:toolswith 18 functions, one user question,max_tokens 120; 5,156 tokens come before the question. Send it 5 times alone, a different question each time.max_tokens 600,"strata_checkpoint": false); 3 s later send the agent request with a new question; wait for both.The prefix is our assistant's private prompt and is not attached. We have only run the probe with it.
What the log shows
0.2.7, from round 2's agent request to round 3's:
Round 2's agent conversation is read in the main session (2 checkpoints), decoded in slot 1, and its main-session copy is
parked (5175 tokens). In round 3 the long answer goes to slot 1:
park_slot(1)parks what slot 1 holds (round 2's agentconversation with its reply, 5206 tokens) and drops the 5175-token copy as superseded. Nothing parked then has the
5156-token checkpoint, and round 3's agent request reads everything.
0.2.6, same point:
Why (our reading of the v0.2.7 code; not checked beyond the runs above)
(
src/program/generate.cpparound L17102,sl.checks.push_back(*best)): for an agent request its turn checkpoint, notthe one at the end of the shared prefix that the next requests borrow.
park_slot(L12603) goes throughpark_source, which callsconversations.drop_superseded(src.ids, src.imgs, src.checks, src.cvec)(L10470), andConversationCache::put()calls it again (conversation_cache.hppL493).drop_superseded(#342, L442) drops a parked entry when the outgoing chain holds that entry's deepest checkpoint. Themain-session copy of the same conversation qualifies, and its checkpoint at the end of the shared prefix goes with it.
The rule assumes the outgoing chain also carries the older checkpoints, which is true for the main session's chain but
not for a slot's.
--conversation-cache-mib 1024, an agent conversation's main copy is 401 MB, aslot image 283 MB (agent) or 120-124 MB (long answer). With them parked the cache holds one main copy where 0.2.6 holds
two (
parked=2 bytes=801891680above), so the older copies with the shared checkpoint had been evicted, and thedropped one was the last. This part is reconstructed from the
parked=,bytes=andevictions=fields; the log doesnot say which entry an eviction removes.
The change we run
ConversationCache::supersedes_richer(ids, images, checkpoints, cvec)is true whendrop_supersededwith that chainwould drop an entry that has a checkpoint the chain does not hold.
park_slotthen returns early and says so; the slot isoverwritten as in 0.2.6, so a continuation of that conversation reads its reply again (about 30 tokens here). A slot with
no such copy (the long answers here) is still parked. With it, at the same point:
Patch against v0.2.7 (3 files, +59)
Ways that would keep the reply as well, not tried: copy the superseded entry's missing checkpoints into the slot's image,
or give a slot the conversation's whole chain at admission.
sycl/src/program/generate.cpphas the samepark_slot; thepatch does not touch it (we have no SYCL device).
Tests:
strata):conversation_cache_test(4842 checks, with the new case),conversation_split_failure_test,conversation_memory_test,conversation_file_test,session_save_reclaim_test,ple_residency_test,arch_defaults_test;python -m unittestofserve.test_frontend,serve.test_answer_speed,serve.test_family_name,serve.test_responses,serve.test_vision_elastic,serve.test_vision_elastic_http,serve.test_vision_start_error,serve.test_cache_drop. The patch applies to plain v0.2.7 (git apply --cached --check); not built there.(4K prompt and decode, long answers, a 100K-token document 6/6, two users, pictures 4/4) stayed within run-to-run noise
of 0.2.6 and 0.2.7.
Strata version
Strata 0.2.7 · engine 0.1.52: upstream v0.2.7 (
3f6d9c28) + local patches (a conversation disk tier that only takesconversations of 16,384+ tokens and did not read or write during these probes, extra
/v1/modelsfields, an elastic CPUimage encoder, an opt-in Q4_0-KV WMMA prompt attention, a gfx1200 hipBLASLt table). The 0.2.6 runs: 0.2.6 · engine
0.1.51 with the same local patches.
Graphics card, memory and system
RX 9060 XT 16 GB (gfx1200, ROCm 7.2.3) · Core i7-12700H · 62 GB RAM, container limited to 52 GiB · Debian 12, kernel 6.18
Model, size and settings
Qwen3.8-Flash-Next IQ2_XS · 512K context · pictures on (CPU encoder) ·
--batch 2 --batch-mtp, MTP drafts(
--spec 4),--kv q4_0, conversation cache 1024 MiB / 6 slotsReproduction status
Reproduced locally
@Niko1221 commented on GitHub (Oct 29, 2026):
Your reading was right, and
supersedes_richer()is the smallest change, so the fix carries it with your test (credited in the commit). Parking an idle--batchslot dropped the main session's copy with the shared system-prompt checkpoint, so the next agent request read the 6,028-token prefix again. Fixed on our side; the fix ships in the next update (0.2.8).On one RTX A6000 (Qwen IQ3_S,
--batch 2, a 6,052-token prefix) the time to first token from round 2 on was 3.3 s before and 0.66 s after. The trade-off you described stays: the slot's own reply is read again if that conversation comes back. Keeping the missing checkpoints (100+ MB each) is left open.@drrck82 commented on GitHub (Oct 29, 2026):
Same failure here on 0.2.7 / engine 0.1.52, but it loses a whole conversation's copy, not just a shared prefix.
Rig. Linux, 2x RTX 3090 (layer split auto: CUDA0 layers 0-21, CUDA1 22-47 + head/draft),
Qwen3.8-Flash-Next GSQ-RCO IQ3_S +
--mtp, engine 0.1.52 (tag v0.2.7,5e8a4cca).Relevant server args:
--batch 4 --batch-mtp --batch-groups auto --kv int8 --kv-resident 32768 --max-context 262144 --conversation-cache-mib 24576 --conversation-cache-slots 8 --conversation-cache-min-tokens 8192 --conversation-cache-min-free-mib 4096,--prompt-cacheand--prompt-cache-everyat their defaults (6 / 16384).STRATA_PIPED_MTP=1in the environment. Client: Claude Code, 8 sessions at once, byte-identicalappend-only prompts (
--batch-groups autoresolves to 2 groups of 2).What it costs. 43 turns since the last restart: 31 full hits (median prefill 0.65 s), 10 turns
restoring a stale checkpoint (median 4.3 s, 52 s in total), 2 cold.
evictions=0throughout and thecache sat at 7.1 GiB of its 24.5 GiB budget, so nothing was evicted for space.
Two conversations alternate, and the parked copy does not survive the other one's park.
Conversation A is at ~66 K, B at ~95 K. Note
parkedstays at 1 although both are served:A parks at 66,320 / 66,474 / 66,576 and B is restored live each time -- yet A's own next turn
restores 54,980, 11.5 K tokens behind the copy it had parked one turn earlier:
A second conversation does the same at 71,364 (5 turns, 4,237-4,539 tokens re-read, 3.5-4.1 s each),
plus one 19,543-token re-read (8.7 s).
Both restore points are on the
--prompt-cache-everygrid (16384): 54980 and 71364 are exactly16,384 apart (
mod 16384 = 5828for both). The previous session on this box showed the same pair at30,404 and 46,788 -- also exactly 16,384 apart. So the restore lands on a periodic checkpoint, not on
the turn-boundary state. Per #2228's diagnosis, the prompt is a pure append, so the deeper state
should have matched; the sibling conversation's grid checkpoint is winning because the requester's own
copy is gone.
The question. Your 0.2.8 note says the fix is
supersedes_richer()and that the trade-off is "theslot's own reply is read again if that conversation comes back". Does that fix also cover this shape,
where the other conversation's park makes
parkedstay at 1 and the next turn of the firstconversation falls back 16,384 tokens? Happy to test a build with the fix on this box (2x 3090,
--batch 4 --batch-mtp, 8 concurrent Claude Code sessions) and report the same breakdown.@Niko1221 commented on GitHub (Oct 29, 2026):
Your reading was right and your test is credited in the commit. Fixed in 0.2.8: parking an idle
--batchslot no longer drops the main session's copy with the shared system-prompt checkpoint. On one RTX A6000 the time to first token from round 2 on went from 3.3 s to 0.66 s. Keeping the other checkpoints (100+ MB each) is still open. Runstrata update. Closing.