mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2518] [Engine] Branching follow-ups can be admitted into the wrong batch slot and lose another conversation's cached prefix affects Strata v0.2.6 #1021
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#1021
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 @rriggs on GitHub (Oct 15, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2518
Area
[Engine]
What do you want to do?
Concurrent prefill appears to break prefix cache use.
This is backend-agnostic. See the re-opening comment below.
Strata version
Reproduced on Strata 0.2.6 on CPU.
My system:
Intel B70 32GB, PCIE5.0x16
AMD 7950X
128GB DDR5
Model: QFN-GSQ-RCO-IQ3_S
Reproducer
llama-benchyrun with--concurrency 2against a Strata server running--batch 2never uses prefix cache.Note: using
llama-benchyagainst Strata requires this patch: https://github.com/eugr/llama-benchy/pull/33Correct Behavior with
--concurrency 1Here
llama-benchyis run with--concurrency 1, performance is as expected for a cached prefix. And the monitor shows the prefix reused.Strata Monitor Output
Strata Monitor shows that the prefix is reused as expected.
Incorrect behavior with
--concurrency 2Here
llama-benchyis run with--concurrency 2, prefill performance tanks for what should be a cached prefix. And the monitor shows no prefix use.Strata Monitor Output
Strata Monitor shows no prefix reuse. The top two requests should re-use the prefix from the bottom two.
@qni-live commented on GitHub (Oct 17, 2026):
Adding measurements from a 4-slot setup. It is the same symptom as in this report, seen with multi-turn chats instead of
llama-benchy, and it narrows it down to the pipelined groups.Setup: 2x RTX PRO 4500 Blackwell (sm_120, 200 W, Linux), Swift IQ3_XXS, 95 % of the experts in VRAM,
layer_split25,--batch 4 --trim-stage-weights, vision on the CPU. v0.1.44.1 and v0.1.45 behave the same.What I ran. Four chats at the same moment, five turns each. Every turn appends about 1,700 tokens of new text to the chat so far, including the model's own answers (script below). For a pure append, about 72 % of the follow-up tokens can come from the cache (50 / 67 / 75 / 80 % for turns 2 to 5). Token share served from the cache over all follow-up turns (16 turns per run):
--batch 4,--batch-groupsauto (2 groups of 2), 0.1.44.1pick_slotchange)--batch 4 --batch-groups 1--batch 4 --batch-groups 1 --batch-mtpWith pipelined groups roughly half of the reusable tokens are read again, also on 0.1.45. With
--batch-groups 1the cache works as in the solo case (50 / 67 / 74 / 79 % per turn, the ideal).--batch-mtpmakes no difference to this; it is the group setting.What
--batch-groups 1costs. For independent cold prompts it is slower (8k prompts, total tok/s, two runs each, interleaved with the default): 1 / 2 / 3 / 4 requests +1 % / -16 % / -12 % / -17 %; at 32k -25 % / -32 % / -39 % for 2 / 3 / 4 requests. A single request is unchanged. So it is a workaround for chat-style traffic, not a free fix.Real traffic. Our server log (agent sessions, requests with at least 4,000 context tokens, one request running alone): cache share 82.6 % and first token p50 0.65 s on the solo build (11 to 14 Oct, 869 requests), 64.9 % and 2.22 s on
--batch 4with auto groups (14 to 17 Oct, 507 requests). Different days and different work, so only a hint.Question. Is the
pick_slotchange meant to cover the pipelined groups? In my runs 0.1.45 is not reliably better than 0.1.44.1 (one run 53 %, two runs 37 to 39 %). I can send an engine log of a run if that helps.mt.py (about 45 lines, standard library only)
Written with AI assistance (Claude); numbers reviewed by me.
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. 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.
@rriggs commented on GitHub (Oct 26, 2026):
/reopen
I have narrowed down one cause of the prefix-reuse failures in this issue and attached a small server-only patch with regression tests. Please feel free to pick up or adapt the change; I am leaving integration to the maintainer rather than opening a PR.
Current-version reproduction
The CPU slot-selection regression reproduces on both v0.2.6 and current
main,4b9e05a2a806a3fe24f7b2560d98626c37dade35. TheirStrataEngine.pick_slot()implementations are AST-identical to the earlier test base,7dd5cf18e68c639a8773e096c5c7 9f971ea2a9f5.I fetched the actual function from each version and executed the attached branching test against it with a lightweight slot-sta
te fixture. Both fail with:
This is a current-version CPU reproduction of the routing defect, not a claim that I rebuilt and ran the v0.2.6 engine on the GPU. The runtime comparison below uses my older deployed SYCL engine, unchanged between arms.
Cause
There are two separate decisions:
pick_slot()chooses an admission destination and sendsBGEN <slot>.nd eventually copies the result into the already-chosen destination.
The Python selector recognizes the complete held stream or a prefix ending at its last turn-start marker. A branching request can replace the final question while still matching an earlier message-boundary checkpoint. Python misses that match, falls back to LRU, and can choose another conversation's slot. The engine then finds the right source, but that does not change the admission destination.
Observed baseline sequence:
That unnecessarily overwrites another chat's idle-slot copy. Host-cache eviction can then leave that chat without a usable copy
when its follow-up arrives.
Smallest CPU reproduction
The attached
serve/test_parallel.pytestPickSlot.test_a_branch_goes_to_its_earlier_message_boundarysets up four populatedidle slots, each with a distinct history longer than 8192 tokens. Slot 0 is least recently used. The request shares slot 1's history through the earlier message boundary but changes the final question before the last assistant marker.
Expected: choose slot 1. Unpatched: chooses slot 0.
To reproduce the failure before installing the implementation, apply just the test hunk:
Then apply the implementation and rerun:
If starting from an untouched checkout, the complete patch can instead be applied in one step with
git apply strata-2518-branch-slot-affinity.patch.Runtime A/B
Hardware/system: one Intel Arc Pro B70, 32 GB VRAM; Ryzen 9 7950X; approximately 128 GB system RAM (
MemTotal: 130967440 kB);Linux
7.2.9-200.fc44.x86_64. Server and SYCL engine run inside an Ubuntu 24.04 container.Model: original Qwen3.8-Flash-Next GSQ-RCO IQ3_S native pack. Four slots, 131072 maximum context per slot, int8 KV, 32768 resident KV cells, conversation parking budget 4096 MiB/four entries,
STRATA_CACHE_MESSAGE_BOUNDARY=1, MTP spec 4/min-p 0.5. Greedy requests with thinking disabled and a 128-token output cap.The runtime engine is the older local
sycl-039deployment with its existing checkpoint fixes, not a pristine current release.Its executable SHA-256 was identical before and after:
78b9f25021a4f073763fa739ff80bc6543244704298f41900cf2eeb56aa69f6d. Only the Pythonpick_slot()method changed. Both arms used a fresh server start and identical request bodies.Four distinct ALPHA/BRAVO/CEDAR/DELTA record histories were loaded concurrently, then four branching follow-ups were submitted concurrently. The follow-ups replace the final question; they are not pure appends and are not four copies of an identical long prefix. Cold prompts were 12235 tokens, follow-ups 12236 tokens.
The engine's per-prompt lines corroborate the API counters. With the patch, the source/admission pairs were
1 -> 1,0 -> 0,2 -> 2,3 -> 3and every follow-up resumed its boundary. Additional internal one-token readmissions were not counted as separate clients.After restoring the normal two-slot/262144-context configuration, both branching follow-ups reused 12213 tokens and read 23. All tested replies were nonempty; a separate text smoke returned the expected answer.
Patch and validation
Attachment:
strata-2518-branch-slot-affinity.patch.txt(plain unified diff; rename to.patch, or use the attached name directly withgit apply).serve/server.py: +14/-2, including comments. Score shared earlier message boundaries as slot-affinity hints rather than arbitrary common token prefixes.serve/test_parallel.py: +36/-0. Branch regression plus controls for busy slots, whole/contained prompts, continuation, identical-candidate ties, non-message common prefixes, and pipeline policy.7dd5cf18-based fix worktree:python -m unittest serve.test_parallel serve.test_slots serve.test_slot_alloc -vpassed 64 tests.git apply --checkagainst the fetched files from current main4b9e05a2.git diff --checkpassed.The selector is still an affinity hint, not a mirror of the engine's checkpoint inventory. Only the engine determines whether a
snapshot actually exists and validates token/image/state compatibility. The patch does not force reuse or modify engine checkpoint handling.
Limits
One cold/follow cycle per runtime arm, not a soak or throughput benchmark. The broader server test discovery run hit a 180-second timeout, so I am not claiming a complete server-suite pass. No CUDA/HIP runtime validation or current-v0.2.6 GPU run was performed. The multi-slot pipeline-group selection path is unchanged; this does not establish a fix for the pipelined-group behavior reported elsewhere in this thread, or every possible cause of prefix loss.
Patch, investigation and tests prepared with AI assistance (GPT-6.1-Sol)
strata-2518-branch-slot-affinity.patch.txt
; validation scope and results are stated above.
@github-actions[bot] commented on GitHub (Oct 26, 2026):
Not reopened yet. Still missing:
Edit the issue and comment
/reopenagain. Details: CONTRIBUTING.md@rriggs commented on GitHub (Oct 26, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 26, 2026):
Not reopened yet. Still missing:
Edit the issue and comment
/reopenagain. Details: CONTRIBUTING.md@rriggs commented on GitHub (Oct 26, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 26, 2026):
Reopened, thank you. A maintainer will pick it up from here.
@SunNorthGod commented on GitHub (Nov 1, 2026):
Adding real-world numbers from a public multi-client deployment, since this report matches our production pattern exactly.
Setup: eng 0.1.47, single RTX 5090 32GB + 128GB DDR5, Qwen3.8-Flash-Next UD-Q4_K_XL native pack,
--parallel 2(one local IDE client + one remote API client alternating through an frp tunnel). Cache flags were at defaults:--prompt-cache 6 --prompt-cache-every 16384, conversation cache off.13 consecutive serving requests (
strata serve: prompt ...log lines):0 reusedcost 43.6 s of prefill against 6.3 s of generation (87% of that request was prefill)Patterns in the log, mapped to this report:
--parallel 2, slot A's prefill (compute-bound) visibly stalls slot B's decode; a decode+decode pair coexists far better than prefill+decode.After retuning (
--prompt-cache 16 --prompt-cache-every 8192 --conversation-cache-mib 6144 --conversation-cache-slots 8) I'll re-run the same trace and post the delta.Question for the maintainers: is per-slot ownership of checkpoint admission (a per-slot quota instead of the global LRU) something the engine design could accommodate, or is the fix strictly in the branching/admission logic described here?
@Niko1221 commented on GitHub (Nov 5, 2026):
Hello rriggs,
Thank you for the analysis and patch, it saved us time. In Strata 0.2.11 the slot picker looks for the latest turn marker at the point where the new prompt and a held conversation stop agreeing (from 8192 tokens in), and ignores a boundary every held conversation shares, so a branching follow-up goes to its own chat's slot. We wrote the code in our tree. We measured it in a simulation of four chats with interleaved branching follow-ups (retained prefix 83% to 100%); we did not run it on a GPU. Pipelined groups of more than one are unchanged by design. If a branch still loses another chat's cache on 0.2.11, please send the serve log with the slot numbers.
The Strata project