[GH-ISSUE #5145] [Engine] Qwen3.6-35B-A3B (q36): strata_prefix / pin=N is ignored, a shared long prefix is re-read on every request #3058

Open
opened 2026-11-07 14:37:42 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @fedororsanskij28819-beep on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5145

What happens

On the Qwen3.6-35B-A3B engine path (qwen35moe, strata-q36), a request with "strata_prefix" gets no reuse: every request
reads its whole prompt from token 0. With the same client code on Qwen3.8-Flash-Next, the pinned prefix works as documented
(9650 reused, prompt read 13–17 s → 1.5–3 s).

Workload: a batch of independent single-turn requests. Each prompt = the same ~9,650-token read-only document (opens the user
message) + a short, different question. strata_prefix: {"message": 1, "chars": <end of the document>} on every request.

Engine log on q36, every request:

strata serve: session 0: prompt ~10000 tokens = 0 reused + ~10000 read in ~57000 ms (~170 tok/s), ...

(20 of 20 requests: 0 reused.) The prompt read is ~57 s of a ~60 s request, so the pin is the whole difference.

Why (from reading the code)

  • serve/server.py (~L1450) turns the resolved strata_prefix into pin=N on the engine's request line — for both families.
  • The q36 request parser (src/qwen35/q36_engine.cu, key loop ~L3460) accepts only the sampling keys and img_keys; an
    unknown key=value is skipped silently, so pin is dropped without a log line.
  • q36 has no prompt checkpoints: reuse is match_len (~L3404) — the session's whole held token list (prompt and answer)
    must be a proper start of the new prompt, because the recurrent (GDN) state cannot step back. Two requests that share only
    a prefix therefore never match.
  • The pieces for a fix seem to be there already: several sessions (n_sess, up to kVerify = 8) and
    Engine::copy_session(src, dst) (recurrent state + the first pos KV cells).

Ask

  1. Support pin=N on q36: while reading a prompt, snapshot the session's state at token N (into a spare session or a
    dedicated "prefix" buffer: recurrent state + conv state + KV cells [0, N)), and on a later request whose ids start with
    the same N tokens, copy_session from it and read only the rest. One pinned prefix per engine would already cover our case
    (the same rule as Flash-Next).
  2. Until then: a log line when pin= is given to an engine that does not support it (like the server's
    strata_prefix ... ignored: ... messages), so the cost is visible.

Setup

  • Strata 0.1.48.1 (CLI commit 7b3e2ea), engine 0.1.48 (BUILD.json commit 6f8800aefe), Windows 11, CUDA 13 build.
    Code references above are from GitHub main at 7dd5cf1.
  • i5-12400F, 32 GB DDR4, RTX 5060 8 GB (PCIe 4.0 x8). Hybrid mode: 11 of 256 experts per layer in VRAM, the rest on the CPU.
  • --native <gguf> --max-context 16384 --prefill auto --mtp 2, one session.
  • Model file: a community Qwen3.6-35B-A3B GGUF with the MTP layer, Q5_K_M (753 tensors, nextn_predict_layers = 1; the engine
    accepted it: 753 tensors (layout checked), MTP block loaded). It is not one of the pinned Unsloth files — but the
    behaviour above follows from the request parser and match_len, so it should not depend on the file. Not re-tested with
    UD-Q4_K_XL.

Side note (may be a separate issue): in the same runs draft_n stayed 0 (no MTP drafts accepted or offered) on short
greedy-ish requests with reasoning_effort: none. Not investigated yet.

Originally created by @fedororsanskij28819-beep on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5145 **What happens** On the Qwen3.6-35B-A3B engine path (`qwen35moe`, `strata-q36`), a request with `"strata_prefix"` gets no reuse: every request reads its whole prompt from token 0. With the same client code on Qwen3.8-Flash-Next, the pinned prefix works as documented (`9650 reused`, prompt read 13–17 s → 1.5–3 s). Workload: a batch of independent single-turn requests. Each prompt = the same ~9,650-token read-only document (opens the user message) + a short, different question. `strata_prefix: {"message": 1, "chars": <end of the document>}` on every request. Engine log on q36, every request: ``` strata serve: session 0: prompt ~10000 tokens = 0 reused + ~10000 read in ~57000 ms (~170 tok/s), ... ``` (20 of 20 requests: `0 reused`.) The prompt read is ~57 s of a ~60 s request, so the pin is the whole difference. **Why (from reading the code)** - `serve/server.py` (~L1450) turns the resolved `strata_prefix` into ` pin=N` on the engine's request line — for both families. - The q36 request parser (`src/qwen35/q36_engine.cu`, key loop ~L3460) accepts only the sampling keys and `img_keys`; an unknown `key=value` is skipped silently, so `pin` is dropped without a log line. - q36 has no prompt checkpoints: reuse is `match_len` (~L3404) — the session's whole held token list (prompt **and** answer) must be a proper start of the new prompt, because the recurrent (GDN) state cannot step back. Two requests that share only a prefix therefore never match. - The pieces for a fix seem to be there already: several sessions (`n_sess`, up to `kVerify` = 8) and `Engine::copy_session(src, dst)` (recurrent state + the first `pos` KV cells). **Ask** 1. Support `pin=N` on q36: while reading a prompt, snapshot the session's state at token N (into a spare session or a dedicated "prefix" buffer: recurrent state + conv state + KV cells `[0, N)`), and on a later request whose ids start with the same N tokens, `copy_session` from it and read only the rest. One pinned prefix per engine would already cover our case (the same rule as Flash-Next). 2. Until then: a log line when `pin=` is given to an engine that does not support it (like the server's `strata_prefix ... ignored: ...` messages), so the cost is visible. **Setup** - Strata 0.1.48.1 (CLI commit 7b3e2ea), engine 0.1.48 (`BUILD.json` commit 6f8800aefe27), Windows 11, CUDA 13 build. Code references above are from GitHub `main` at 7dd5cf1. - i5-12400F, 32 GB DDR4, RTX 5060 8 GB (PCIe 4.0 x8). Hybrid mode: 11 of 256 experts per layer in VRAM, the rest on the CPU. - `--native <gguf> --max-context 16384 --prefill auto --mtp 2`, one session. - Model file: a community Qwen3.6-35B-A3B GGUF with the MTP layer, Q5_K_M (753 tensors, `nextn_predict_layers = 1`; the engine accepted it: `753 tensors (layout checked)`, `MTP block loaded`). It is not one of the pinned Unsloth files — but the behaviour above follows from the request parser and `match_len`, so it should not depend on the file. Not re-tested with UD-Q4_K_XL. Side note (may be a separate issue): in the same runs `draft_n` stayed 0 (no MTP drafts accepted or offered) on short greedy-ish requests with `reasoning_effort: none`. Not investigated yet.
Author
Owner

@pdmaclennan-art commented on GitHub (Nov 4, 2026):

Same cause seen from the agent side, without strata_prefix: on 0.2.10 (engine 0.1.56, Windows HIP, Strix Halo gfx1151) the q36 path reused nothing for repeats and follow-up turns either, so an agent client re-reads its whole conversation every turn.

Six requests in a row on one server (Unsloth Qwen3.6-35B-A3B-MTP-GGUF UD-Q4_K_XL, setup's config --native <gguf> --max-context 131072 --prefill auto --mtp 2), an 18K-token system prompt, up to 200 new tokens, reasoning_budget_tokens: 100:

Request, in order Prompt tokens cached_tokens Seconds
1. fresh, thinking off 18,022 0 33.3
2. the same request again 18,022 0 33.2
3. request 1, its answer and a new question, thinking off 18,082 0 33.6
4. same system prompt, a different question 18,024 0 34.3
5. same system prompt, thinking on 18,022 0 36.2
6. request 5, its answer (without the reasoning, as agent clients send it) and a new question, thinking on 18,066 0 67.9

The engine log agrees (prompt 18066 tokens = 0 reused + 18066 read in 31813 ms for request 6). Of the 54 engine requests that day, one reused anything: the server's own continuation after request 5's thinking budget (18122 reused + 18 read), which sends back exactly the generated tokens. The same continuation after request 6 read all 18,184 tokens again, which is why it took 67.9 s.

So match_len bites even for a plain follow-up: request 3 sends back the answer as text, and that did not match the held tokens either (with thinking on, the template drops the reasoning, so it cannot).

For comparison, on the same machine and harness, Flash-Next Q2_0 with setup's settings reused 18,005-18,055 tokens on requests 2, 3, 4 and 6 and answered them in 0.5-1.4 s (request 5, the first with thinking on after thinking-off requests, read everything again). llama.cpp on the same 35B file started its second turn in 0.4-0.5 s. A state snapshot at the end of the prompt (or at the last user turn), as you describe under "Ask", would cover the agent case too.

Full report and logs: https://github.com/Niko1221/Strata/pull/5182.

<!-- gh-comment-id:6623864740 --> @pdmaclennan-art commented on GitHub (Nov 4, 2026): Same cause seen from the agent side, without `strata_prefix`: on 0.2.10 (engine 0.1.56, Windows HIP, Strix Halo gfx1151) the q36 path reused nothing for repeats and follow-up turns either, so an agent client re-reads its whole conversation every turn. Six requests in a row on one server (Unsloth Qwen3.6-35B-A3B-MTP-GGUF UD-Q4_K_XL, setup's config `--native <gguf> --max-context 131072 --prefill auto --mtp 2`), an 18K-token system prompt, up to 200 new tokens, `reasoning_budget_tokens: 100`: | Request, in order | Prompt tokens | `cached_tokens` | Seconds | | --- | ---: | ---: | ---: | | 1. fresh, thinking off | 18,022 | 0 | 33.3 | | 2. the same request again | 18,022 | 0 | 33.2 | | 3. request 1, its answer and a new question, thinking off | 18,082 | 0 | 33.6 | | 4. same system prompt, a different question | 18,024 | 0 | 34.3 | | 5. same system prompt, thinking on | 18,022 | 0 | 36.2 | | 6. request 5, its answer (without the reasoning, as agent clients send it) and a new question, thinking on | 18,066 | 0 | 67.9 | The engine log agrees (`prompt 18066 tokens = 0 reused + 18066 read in 31813 ms` for request 6). Of the 54 engine requests that day, one reused anything: the server's own continuation after request 5's thinking budget (`18122 reused + 18 read`), which sends back exactly the generated tokens. The same continuation after request 6 read all 18,184 tokens again, which is why it took 67.9 s. So `match_len` bites even for a plain follow-up: request 3 sends back the answer as text, and that did not match the held tokens either (with thinking on, the template drops the reasoning, so it cannot). For comparison, on the same machine and harness, Flash-Next Q2_0 with setup's settings reused 18,005-18,055 tokens on requests 2, 3, 4 and 6 and answered them in 0.5-1.4 s (request 5, the first with thinking on after thinking-off requests, read everything again). llama.cpp on the same 35B file started its second turn in 0.4-0.5 s. A state snapshot at the end of the prompt (or at the last user turn), as you describe under "Ask", would cover the agent case too. Full report and logs: https://github.com/Niko1221/Strata/pull/5182.
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#3058
No description provided.