[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

Closed
opened 2026-11-04 01:47:48 +07:00 by bsakaguchi · 10 comments
Owner

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-benchy run with --concurrency 2 against a Strata server running --batch 2 never uses prefix cache.

Note: using llama-benchy against Strata requires this patch: https://github.com/eugr/llama-benchy/pull/33

Correct Behavior with --concurrency 1

Here llama-benchy is run with --concurrency 1, performance is as expected for a cached prefix. And the monitor shows the prefix reused.

llama-benchy --base-url http://***:8081/v1 --model qwen38-flash-n
ext   --tokenizer Qwen/Qwen3.8-Flash-Next --depth 8192 --tg 128 --runs 1 --pp 2048 --concurrency 2 --enable-prefix-caching   --exit-on-first-fail --latency-mode generation --no-warmup
model test t/s peak t/s ttfr (ms) est_ppt (ms) e2e_ttft (ms)
qwen38-flash-next ctx_pp @ d8192 1087.24 ± 0.00 5.59 ± 0.00 7536.53 ± 0.00 7538.09 ± 0.00
qwen38-flash-next ctx_tg @ d8192 41.84 ± 0.00 42.00 ± 0.00
qwen38-flash-next pp2048 @ d8192 733.33 ± 0.00 6.84 ± 0.00 2792.72 ± 0.00 2794.29 ± 0.00
qwen38-flash-next tg128 @ d8192 47.25 ± 0.00 48.00 ± 0.00

Strata Monitor Output

Strata Monitor shows that the prefix is reused as expected.

TIME STATUS PROMPT REUSED OUTPUT PREFILL T/S DECODE T/S VRAM HIT RATE DURATION
05:04:01 PM Max tokens 10,242 8,183 128 721 44.1 87.4% +3.7% PCIe 5.8 s
05:03:50 PM Max tokens 8,194 0 128 1,067 39.1 89.1% +2.8% PCIe 11.0 s

Incorrect behavior with --concurrency 2

Here llama-benchy is run with --concurrency 2, prefill performance tanks for what should be a cached prefix. And the monitor shows no prefix use.

llama-benchy --base-url http://***:8081/v1 --model qwen38-flash-n
ext   --tokenizer Qwen/Qwen3.8-Flash-Next --depth 8192 --tg 128 --runs 1 --pp 2048 --concurrency 2 --enable-prefix-caching   --exit-on-first-fail --latency-mode generation --no-warmup
model test t/s (total) t/s (req) peak t/s peak t/s (req) ttfr (ms) est_ppt (ms) e2e_ttft (ms)
qwen38-flash-next ctx_pp @ d8192 (c2) 978.87 ± 0.00 794.07 ± 304.61 15.31 ± 0.79 12099.93 ± 4640.99 12101.58 ± 4640.99
qwen38-flash-next ctx_tg @ d8192 (c2) 18.64 ± 0.00 19.84 ± 9.38 41.00 ± 0.00 20.50 ± 9.50
qwen38-flash-next pp2048 @ d8192 (c2) 188.50 ± 0.00 149.95 ± 55.69 25.93 ± 1.18 15843.08 ± 5883.94 15844.73 ± 5883.94
qwen38-flash-next tg128 @ d8192 (c2) 15.82 ± 0.00 19.20 ± 10.39 39.00 ± 0.00 19.50 ± 10.50

Strata Monitor Output

Strata Monitor shows no prefix reuse. The top two requests should re-use the prefix from the bottom two.

TIME STATUS PROMPT REUSED OUTPUT PREFILL T/S DECODE T/S VRAM HIT RATE DURATION
04:48:22 PM Max tokens 10,241 0 128 889 31.9 91.1% +2.1% PCIe 26.0 s
04:48:22 PM Max tokens 10,242 0 128 1,034 9.0 95.8% +0.2% PCIe 24.3 s
04:48:01 PM Max tokens 8,194 0 128 907 31.3 91.3% +2.2% PCIe 21.1 s
04:48:01 PM Max tokens 8,195 0 128 1,105 10.6 96.2% +0.2% PCIe 19.6 s
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-benchy` run with `--concurrency 2` against a Strata server running `--batch 2` never uses prefix cache. Note: using `llama-benchy` against Strata requires this patch: https://github.com/eugr/llama-benchy/pull/33 ## Correct Behavior with `--concurrency 1` Here `llama-benchy` is run with `--concurrency 1`, performance is as expected for a cached prefix. And the monitor shows the prefix reused. ``` llama-benchy --base-url http://***:8081/v1 --model qwen38-flash-n ext --tokenizer Qwen/Qwen3.8-Flash-Next --depth 8192 --tg 128 --runs 1 --pp 2048 --concurrency 2 --enable-prefix-caching --exit-on-first-fail --latency-mode generation --no-warmup ``` | model | test | t/s | peak t/s | ttfr (ms) | est_ppt (ms) | e2e_ttft (ms) | |:------------------|---------------:|---------------:|-------------:|------------:|---------------:|----------------:| | qwen38-flash-next | ctx_pp @ d8192 | 1087.24 ± 0.00 | | 5.59 ± 0.00 | 7536.53 ± 0.00 | 7538.09 ± 0.00 | | qwen38-flash-next | ctx_tg @ d8192 | 41.84 ± 0.00 | 42.00 ± 0.00 | | | | | qwen38-flash-next | pp2048 @ d8192 | 733.33 ± 0.00 | | 6.84 ± 0.00 | 2792.72 ± 0.00 | 2794.29 ± 0.00 | | qwen38-flash-next | tg128 @ d8192 | 47.25 ± 0.00 | 48.00 ± 0.00 | | | | ### Strata Monitor Output Strata Monitor shows that the prefix is reused as expected. TIME| STATUS| PROMPT| REUSED| OUTPUT| PREFILL T/S| DECODE T/S| VRAM HIT RATE| DURATION -|-|-|-|-|-|-|-|- 05:04:01 PM| Max tokens| 10,242| 8,183| 128| 721| 44.1| 87.4% +3.7% PCIe| 5.8 s 05:03:50 PM| Max tokens| 8,194| 0| 128| 1,067| 39.1| 89.1% +2.8% PCIe| 11.0 s ## Incorrect behavior with `--concurrency 2 ` Here `llama-benchy` is run with `--concurrency 2`, prefill performance tanks for what should be a cached prefix. And the monitor shows no prefix use. ``` llama-benchy --base-url http://***:8081/v1 --model qwen38-flash-n ext --tokenizer Qwen/Qwen3.8-Flash-Next --depth 8192 --tg 128 --runs 1 --pp 2048 --concurrency 2 --enable-prefix-caching --exit-on-first-fail --latency-mode generation --no-warmup ``` | model | test | t/s (total) | t/s (req) | peak t/s | peak t/s (req) | ttfr (ms) | est_ppt (ms) | e2e_ttft (ms) | |:------------------|--------------------:|--------------:|----------------:|-------------:|-----------------:|-------------:|-------------------:|-------------------:| | qwen38-flash-next | ctx_pp @ d8192 (c2) | 978.87 ± 0.00 | 794.07 ± 304.61 | | | 15.31 ± 0.79 | 12099.93 ± 4640.99 | 12101.58 ± 4640.99 | | qwen38-flash-next | ctx_tg @ d8192 (c2) | 18.64 ± 0.00 | 19.84 ± 9.38 | 41.00 ± 0.00 | 20.50 ± 9.50 | | | | | qwen38-flash-next | pp2048 @ d8192 (c2) | 188.50 ± 0.00 | 149.95 ± 55.69 | | | 25.93 ± 1.18 | 15843.08 ± 5883.94 | 15844.73 ± 5883.94 | | qwen38-flash-next | tg128 @ d8192 (c2) | 15.82 ± 0.00 | 19.20 ± 10.39 | 39.00 ± 0.00 | 19.50 ± 10.50 | | | | ### Strata Monitor Output Strata Monitor shows no prefix reuse. The top two requests should re-use the prefix from the bottom two. TIME|STATUS| PROMPT| REUSED| OUTPUT| PREFILL T/S| DECODE T/S| VRAM HIT RATE| DURATION -|-|-|-|-|-|-|-|- 04:48:22 PM| Max tokens| 10,241| 0| 128| 889| 31.9| 91.1% +2.1% PCIe| 26.0 s 04:48:22 PM| Max tokens| 10,242| 0| 128| 1,034| 9.0| 95.8% +0.2% PCIe| 24.3 s 04:48:01 PM| Max tokens| 8,194| 0| 128| 907| 31.3| 91.3% +2.2% PCIe| 21.1 s 04:48:01 PM| Max tokens| 8,195| 0| 128| 1,105| 10.6| 96.2% +0.2% PCIe| 19.6 s
Author
Owner

@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_split 25, --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):

Setup cache share turn time p50 all four chats
solo (1 slot), one chat 70.0 % 1.3 s n/a
--batch 4, --batch-groups auto (2 groups of 2), 0.1.44.1 42.2 % / 37.4 % 6.8 / 8.1 s 34.1 / 35.1 s
same, 0.1.45 (with the pick_slot change) 53.0 % / 36.8 % 4.9 / 7.3 s 33.1 / 35.8 s
same, 0.1.45, again 39.3 % / 37.2 % 7.4 / 7.1 s 35.1 / 35.8 s
--batch 4 --batch-groups 1 70.9 % / 70.9 % 5.1 / 3.8 s 26.3 / 26.0 s
--batch 4 --batch-groups 1 --batch-mtp 70.9 % / 70.9 % 4.1 / 5.2 s 26.3 / 26.5 s

With pipelined groups roughly half of the reusable tokens are read again, also on 0.1.45. With --batch-groups 1 the cache works as in the solo case (50 / 67 / 74 / 79 % per turn, the ideal). --batch-mtp makes no difference to this; it is the group setting.

What --batch-groups 1 costs. 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 4 with auto groups (14 to 17 Oct, 507 requests). Different days and different work, so only a hint.

Question. Is the pick_slot change 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)
#!/usr/bin/env python3
"""mt.py OUT.json [N] : N Unterhaltungen gleichzeitig, je 5 Zuege; jeder Zug haengt neuen Text an die bisherige Unterhaltung an
(Antworten des Modells inklusive). Misst je Zug, wie viele Prompt-Tokens aus dem Konversations-Cache kamen (timings.cache_n)."""
import json, sys, time, threading, urllib.request, random, pathlib, statistics
OUT = sys.argv[1]; N = int(sys.argv[2]) if len(sys.argv) > 2 else 4; T = 5
docs = sorted(pathlib.Path.home().glob("ai/Strata-0.1.44.1/docs/*.md"))
words = " ".join(p.read_text(errors="ignore") for p in docs[:60]).split()
res = []; lock = threading.Lock()
def ask(msgs):
    body = {"model": "swift-1.5-iq3_xxs", "messages": msgs, "max_tokens": 48, "temperature": 0,
            "reasoning_effort": "none", "chat_template_kwargs": {"enable_thinking": False}}
    r = urllib.request.Request("http://127.0.0.1:8080/v1/chat/completions", json.dumps(body).encode(), {"Content-Type": "application/json"})
    t0 = time.time(); d = json.load(urllib.request.urlopen(r, timeout=900)); return d, time.time() - t0
def conv(c):
    nonce = random.random(); off = c * 9000
    msgs = [{"role": "system", "content": f"You are a careful assistant. Session {c} tag {nonce}."}]
    for t in range(T):
        chunk = " ".join(words[off + t * 1200: off + (t + 1) * 1200])
        msgs.append({"role": "user", "content": f"Part {t + 1} of a document:\n{chunk}\nReply with one short sentence."})
        try:
            d, w = ask(msgs)
        except Exception as e:
            with lock: res.append(dict(conv=c, turn=t, error=str(e)[:120]))
            return
        tm = d.get("timings") or {}; u = d.get("usage") or {}
        pt = u.get("prompt_tokens") or (tm.get("cache_n", 0) + tm.get("prompt_n", 0))
        with lock: res.append(dict(conv=c, turn=t, wall_s=round(w, 2), prompt_tokens=pt, cache_n=tm.get("cache_n"), prompt_n=tm.get("prompt_n")))
        msgs.append({"role": "assistant", "content": d["choices"][0]["message"].get("content") or "ok"})
ask([{"role": "user", "content": "Say hi."}])
ths = [threading.Thread(target=conv, args=(c,)) for c in range(N)]
t0 = time.time(); [x.start() for x in ths]; [x.join() for x in ths]
res.sort(key=lambda r: (r["conv"], r["turn"]))
json.dump(res, open(OUT, "w"), indent=1)
for r in res: print(r)
fu = [r for r in res if r.get("turn", 0) >= 1 and "error" not in r]
if fu:
    tot = sum(r["prompt_tokens"] for r in fu); hit = sum((r["cache_n"] or 0) for r in fu)
    print("ZUSAMMENFASSUNG N=%d: Folgezuege %d, Cache-Treffer %.1f %% (%d von %d Tokens), Zug-Dauer p50 %.2f s, gesamt %.1f s, Fehler %d"
          % (N, len(fu), 100.0 * hit / tot, hit, tot, statistics.median(r["wall_s"] for r in fu), time.time() - t0, sum(1 for r in res if "error" in r)))

Written with AI assistance (Claude); numbers reviewed by me.

<!-- gh-comment-id:6240123924 --> @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_split` 25, `--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): | Setup | cache share | turn time p50 | all four chats | | --- | ---: | ---: | ---: | | solo (1 slot), one chat | 70.0 % | 1.3 s | n/a | | `--batch 4`, `--batch-groups` auto (2 groups of 2), 0.1.44.1 | 42.2 % / 37.4 % | 6.8 / 8.1 s | 34.1 / 35.1 s | | same, 0.1.45 (with the `pick_slot` change) | 53.0 % / 36.8 % | 4.9 / 7.3 s | 33.1 / 35.8 s | | same, 0.1.45, again | 39.3 % / 37.2 % | 7.4 / 7.1 s | 35.1 / 35.8 s | | `--batch 4 --batch-groups 1` | 70.9 % / 70.9 % | 5.1 / 3.8 s | 26.3 / 26.0 s | | `--batch 4 --batch-groups 1 --batch-mtp` | 70.9 % / 70.9 % | 4.1 / 5.2 s | 26.3 / 26.5 s | With pipelined groups roughly half of the reusable tokens are read again, also on 0.1.45. With `--batch-groups 1` the cache works as in the solo case (50 / 67 / 74 / 79 % per turn, the ideal). `--batch-mtp` makes no difference to this; it is the group setting. **What `--batch-groups 1` costs.** 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 4` with auto groups (14 to 17 Oct, 507 requests). Different days and different work, so only a hint. **Question.** Is the `pick_slot` change 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. <details><summary>mt.py (about 45 lines, standard library only)</summary> ```python #!/usr/bin/env python3 """mt.py OUT.json [N] : N Unterhaltungen gleichzeitig, je 5 Zuege; jeder Zug haengt neuen Text an die bisherige Unterhaltung an (Antworten des Modells inklusive). Misst je Zug, wie viele Prompt-Tokens aus dem Konversations-Cache kamen (timings.cache_n).""" import json, sys, time, threading, urllib.request, random, pathlib, statistics OUT = sys.argv[1]; N = int(sys.argv[2]) if len(sys.argv) > 2 else 4; T = 5 docs = sorted(pathlib.Path.home().glob("ai/Strata-0.1.44.1/docs/*.md")) words = " ".join(p.read_text(errors="ignore") for p in docs[:60]).split() res = []; lock = threading.Lock() def ask(msgs): body = {"model": "swift-1.5-iq3_xxs", "messages": msgs, "max_tokens": 48, "temperature": 0, "reasoning_effort": "none", "chat_template_kwargs": {"enable_thinking": False}} r = urllib.request.Request("http://127.0.0.1:8080/v1/chat/completions", json.dumps(body).encode(), {"Content-Type": "application/json"}) t0 = time.time(); d = json.load(urllib.request.urlopen(r, timeout=900)); return d, time.time() - t0 def conv(c): nonce = random.random(); off = c * 9000 msgs = [{"role": "system", "content": f"You are a careful assistant. Session {c} tag {nonce}."}] for t in range(T): chunk = " ".join(words[off + t * 1200: off + (t + 1) * 1200]) msgs.append({"role": "user", "content": f"Part {t + 1} of a document:\n{chunk}\nReply with one short sentence."}) try: d, w = ask(msgs) except Exception as e: with lock: res.append(dict(conv=c, turn=t, error=str(e)[:120])) return tm = d.get("timings") or {}; u = d.get("usage") or {} pt = u.get("prompt_tokens") or (tm.get("cache_n", 0) + tm.get("prompt_n", 0)) with lock: res.append(dict(conv=c, turn=t, wall_s=round(w, 2), prompt_tokens=pt, cache_n=tm.get("cache_n"), prompt_n=tm.get("prompt_n"))) msgs.append({"role": "assistant", "content": d["choices"][0]["message"].get("content") or "ok"}) ask([{"role": "user", "content": "Say hi."}]) ths = [threading.Thread(target=conv, args=(c,)) for c in range(N)] t0 = time.time(); [x.start() for x in ths]; [x.join() for x in ths] res.sort(key=lambda r: (r["conv"], r["turn"])) json.dump(res, open(OUT, "w"), indent=1) for r in res: print(r) fu = [r for r in res if r.get("turn", 0) >= 1 and "error" not in r] if fu: tot = sum(r["prompt_tokens"] for r in fu); hit = sum((r["cache_n"] or 0) for r in fu) print("ZUSAMMENFASSUNG N=%d: Folgezuege %d, Cache-Treffer %.1f %% (%d von %d Tokens), Zug-Dauer p50 %.2f s, gesamt %.1f s, Fehler %d" % (N, len(fu), 100.0 * hit / tot, hit, tot, statistics.median(r["wall_s"] for r in fu), time.time() - t0, sum(1 for r in res if "error" in r))) ``` </details> *Written with AI assistance (Claude); numbers reviewed by me.*
Author
Owner

@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:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271097630 --> @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: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

@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 . Their StrataEngine.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:

AssertionError: 0 != 1                                                                                                         

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:

  1. Python's pick_slot() chooses an admission destination and sends BGEN <slot>.
  2. The engine independently searches idle slots and their checkpoints for the best source, restores it into the main session, a
    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:

slot 1 gave back 12213 tokens of this conversation (its turn checkpoint)
slot 0 takes 12237 tokens

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.py test PickSlot.test_a_branch_goes_to_its_earlier_message_boundary sets up four populated
idle 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:

git apply --include=serve/test_parallel.py strata-2518-branch-slot-affinity.patch
python -m unittest serve.test_parallel.PickSlot.test_a_branch_goes_to_its_earlier_message_boundary -v

Then apply the implementation and rerun:

git apply --include=serve/server.py strata-2518-branch-slot-affinity.patch
python -m unittest serve.test_parallel serve.test_slots serve.test_slot_alloc -v

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-039 deployment with its existing checkpoint fixes, not a pristine current release.
Its executable SHA-256 was identical before and after: 78b9f25021a4f073763fa739ff80bc6543244704298f41900cf2eeb56aa69f6d. Only the Python pick_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.

Conversation Unpatched reused / read Patched reused / read
ALPHA 12213 / 23 12213 / 23
BRAVO 12213 / 23 12213 / 23
CEDAR 0 / 12236 12213 / 23
DELTA 12213 / 23 12213 / 23

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 -> 3 and 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 with git apply).

  • Two files, 50 insertions / 2 deletions total.
  • 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.
  • On the 7dd5cf18-based fix worktree: python -m unittest serve.test_parallel serve.test_slots serve.test_slot_alloc -v passed 64 tests.
  • The patch passes git apply --check against the fetched files from current main 4b9e05a2.
  • git diff --check passed.

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.

<!-- gh-comment-id:6407390224 --> @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 `**. Their `StrataEngine.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: ```text AssertionError: 0 != 1 ``` 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: 1. Python's `pick_slot()` chooses an admission destination and sends `BGEN <slot>`. 2. The engine independently searches idle slots and their checkpoints for the best source, restores it into the main session, a 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: ```text slot 1 gave back 12213 tokens of this conversation (its turn checkpoint) slot 0 takes 12237 tokens ``` 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.py` test `PickSlot.test_a_branch_goes_to_its_earlier_message_boundary` sets up four populated idle 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: ```sh git apply --include=serve/test_parallel.py strata-2518-branch-slot-affinity.patch python -m unittest serve.test_parallel.PickSlot.test_a_branch_goes_to_its_earlier_message_boundary -v ``` Then apply the implementation and rerun: ```sh git apply --include=serve/server.py strata-2518-branch-slot-affinity.patch python -m unittest serve.test_parallel serve.test_slots serve.test_slot_alloc -v ``` 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-039` deployment with its existing checkpoint fixes, not a pristine current release. Its executable SHA-256 was identical before and after: `78b9f25021a4f073763fa739ff80bc6543244704298f41900cf2eeb56aa69f6d`. Only the Python `pick_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. | Conversation | Unpatched reused / read | Patched reused / read | |---|---:|---:| | ALPHA | 12213 / 23 | 12213 / 23 | | BRAVO | 12213 / 23 | 12213 / 23 | | CEDAR | 0 / 12236 | 12213 / 23 | | DELTA | 12213 / 23 | 12213 / 23 | 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 -> 3` and 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 with `git apply`). - Two files, **50 insertions / 2 deletions** total. - `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. - On the `7dd5cf18`-based fix worktree: `python -m unittest serve.test_parallel serve.test_slots serve.test_slot_alloc -v` passed **64 tests**. - The patch passes `git apply --check` against the fetched files from current main `4b9e05a2`. - `git diff --check` passed. 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](https://github.com/user-attachments/files/33945028/strata-2518-branch-slot-affinity.patch.txt) ; validation scope and results are stated above.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2026):

Not reopened yet. Still missing:

  • Re-test on Strata 0.2.0-beta and name that version in the issue. If it no longer happens, say so in a comment instead.

Edit the issue and comment /reopen again. Details: CONTRIBUTING.md

<!-- gh-comment-id:6407392483 --> @github-actions[bot] commented on GitHub (Oct 26, 2026): Not reopened yet. Still missing: - [ ] Re-test on Strata 0.2.0-beta and name that version in the issue. If it no longer happens, say so in a comment instead. Edit the issue and comment `/reopen` again. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@rriggs commented on GitHub (Oct 26, 2026):

/reopen

<!-- gh-comment-id:6407412709 --> @rriggs commented on GitHub (Oct 26, 2026): /reopen
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2026):

Not reopened yet. Still missing:

  • Re-test on Strata 0.2.0-beta and name that version in the issue. If it no longer happens, say so in a comment instead.

Edit the issue and comment /reopen again. Details: CONTRIBUTING.md

<!-- gh-comment-id:6407414673 --> @github-actions[bot] commented on GitHub (Oct 26, 2026): Not reopened yet. Still missing: - [ ] Re-test on Strata 0.2.0-beta and name that version in the issue. If it no longer happens, say so in a comment instead. Edit the issue and comment `/reopen` again. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@rriggs commented on GitHub (Oct 26, 2026):

/reopen

<!-- gh-comment-id:6407499341 --> @rriggs commented on GitHub (Oct 26, 2026): /reopen
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2026):

Reopened, thank you. A maintainer will pick it up from here.

<!-- gh-comment-id:6407501147 --> @github-actions[bot] commented on GitHub (Oct 26, 2026): Reopened, thank you. A maintainer will pick it up from here.
Author
Owner

@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):

  • prompt time 136.3 s vs decode time 57.9 s — prefill is 70.2% of total serving time
  • prefix reuse 56,019/148,553 = 37.7%
  • worst case: a 16,049-token prompt with 0 reused cost 43.6 s of prefill against 6.3 s of generation (87% of that request was prefill)
  • best case: a 45,564-token prompt with 45,545 reused needed 0.66 s of prefill — the mechanism itself works when the checkpoint survives

Patterns in the log, mapped to this report:

  1. Same-client follow-ups that re-read everything after an injected-context change — consistent with the checkpoint-grid mechanics in #2228, amplified here by only 6 checkpoint slots being LRU-evicted across three active conversations (IDE + 2 tunnel clients).
  2. With --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?

<!-- gh-comment-id:6561467538 --> @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): - prompt time 136.3 s vs decode time 57.9 s — **prefill is 70.2% of total serving time** - prefix reuse 56,019/148,553 = **37.7%** - worst case: a 16,049-token prompt with `0 reused` cost 43.6 s of prefill against 6.3 s of generation (87% of that request was prefill) - best case: a 45,564-token prompt with 45,545 reused needed 0.66 s of prefill — the mechanism itself works when the checkpoint survives Patterns in the log, mapped to this report: 1. Same-client follow-ups that re-read everything after an injected-context change — consistent with the checkpoint-grid mechanics in #2228, amplified here by only 6 checkpoint slots being LRU-evicted across **three** active conversations (IDE + 2 tunnel clients). 2. With `--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?
Author
Owner

@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

<!-- gh-comment-id:6658468817 --> @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
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1021
No description provided.