[GH-ISSUE #3354] [Engine] qwen35moe: the model-card sampling is applied silently and disables MTP drafting (drafts accepted 0 of 0) #1361

Open
opened 2026-11-04 01:50:40 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @conlododo on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3354

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

With a Qwen3.6-35B-A3B (qwen35moe) model, --mtp 2 loads the MTP block and the engine warms up with "a speculative step", but every served request reports drafts accepted 0 of 0, so decode stays at the no-drafting speed (73-88 tok/s where the same machine reaches ~150 tok/s with drafts). Sending the same request straight to the engine's own protocol (GEN 64 <ids> on its stdin, bypassing serve/server.py) produces drafts normally: DONE 64 16 132.3 431.5 length 43 44 (43 of 44 accepted) and DONE 256 16 117.8 1631.6 length 167 176 (167 of 176, ~157 tok/s).

The cause is that the server fills in the model card's sampling when a request names none, and the q36 engine only drafts for a strictly greedy request. In serve/server.py, MODEL_CARD_SAMPLING["qwen35moe"] is {"thinking": {"temperature": 1.0, "top_p": 0.95, "top_k": 20, "presence_penalty": 1.5}, "instruct": {...}}; in src/qwen35/q36_engine.cu:3584 the door is const bool spec = E.mtp_d > 0 && !smp.needs_logits() && !adm; and needs_logits() = temperature > 0 || repeat != 1 || freq != 0 || present != 0 (line 3013). A plain OpenAI request ({"messages": [...], "max_tokens": 64}, no sampling fields) therefore reaches the engine as GEN 64 temperature=1.0 top_p=0.95 top_k=20 penalty_present=1.5 penalty_last_n=64 <ids>, and spec is false for every window. Setups where MTP is the main reason to run this family lose the whole benefit without any error or warning.

Smallest steps or command that reproduce it

# Strata 0.1.45 from source, Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf (753 tensors, 22 GB, 5.15 BPW), --max-context 81920 --mtp 2
# 1) a request that names no sampling, through the server:
curl -s http://127.0.0.1:8081/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"...","messages":[{"role":"user","content":"1+1=?"}],"max_tokens":64}'
#    engine log: drafts accepted 0 of 0, ~74 tok/s

# 2) the same shape, straight to the engine (engine/strata --serve ... on stdin):
GEN 64 1,2,3,4,5,6,7,8,9,10,11,12,13,14
#    DONE 64 16 132.3 431.5 length 43 44    (~150 tok/s)

To see the difference without reading the server sources, point the config's exe at a one-file pass-through proxy that logs stdin before forwarding; that is how the GEN line above was captured.

Reproduction status

Reproduced locally

Strata version

strata 0.1.45 (built from source; engine/strata --version reports strata 0.1.45)

Graphics card, memory and system

RTX 5060 Ti 16 GB · 30 GB RAM · Ubuntu 24.04, Linux 7.0.0-38

Model, size and settings

Qwen3.6-35B-A3B-UD-Q4_K_XL · UD-Q4_K_XL (Unsloth Dynamic, 22 GB, 753 tensors, 5.15 BPW) · context 81920 · --mtp 2 · --prefill auto. The GGUF is an upstream file with a LoRA merged back in; its tensor types were restored to the base file's per-tensor types and it loads normally.

Logs

# straight to the engine (drafting on)
DONE 64 16 132.3 431.5 length 43 44 0 0 0 0 0 0.0 16 0
DONE 256 16 117.8 1631.6 length 167 176 0 0 0 0 0 0.0 16 0

# through serve/server.py, request with no sampling fields (drafting off)
GEN 64 temperature=1.0 top_p=0.95 top_k=20 penalty_present=1.5 penalty_last_n=64 248045,846,198,...
strata serve: session 0: prompt 14 tokens = 0 reused + 14 read in 174 ms (80.5 tok/s), 64 generated in 870 ms (73.6 tok/s), drafts accepted 0 of 0 (length)

# the engine's own view while the block is loaded
strata-q36: context 81920 cells, prompt chunk 2048, MTP block loaded, 4.81 GiB of VRAM free
strata-q36: warmed up in 0.9 s (one prompt chunk, a decode step, a speculative step)

Workaround that works

Put a sampling block in the run config so it overrides the model card's set:

"sampling": { "temperature": 0, "top_p": 1.0, "presence_penalty": 0 }

top_k must be left out (the config validation accepts 1..64 only). With that in place, drafts come back on the same machine and model: code-heavy 300-token output went from ~88 to 104 tok/s at --mtp 2 (187/224 drafts accepted) and 113 tok/s at --mtp 4 (221/320); a 256-token chat answer went from ~77 to 95 tok/s (62/128).

What would help (one of these)

  1. Say it: log one line when MTP is loaded but the resolved sampling rules out drafting (drafts disabled: temperature 1.0), instead of leaving the user to discover it from 0 of 0.
  2. Prefer drafting: when --mtp N is given, keep the request greedy unless the client asked for sampling itself, or document that MTP requires temperature=0 with no penalties and that the model-card set turns it off.
  3. A middle ground: a --mtp-greedy or config switch that drops the model-card defaults when MTP is on, keeping them for the plain path.

Happy to test a patch on a 16 GB and a 32 GB card and report the numbers.

Originally created by @conlododo on GitHub (Oct 20, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3354 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened With a Qwen3.6-35B-A3B (`qwen35moe`) model, `--mtp 2` loads the MTP block and the engine warms up with "a speculative step", but every served request reports `drafts accepted 0 of 0`, so decode stays at the no-drafting speed (73-88 tok/s where the same machine reaches ~150 tok/s with drafts). Sending the same request straight to the engine's own protocol (`GEN 64 <ids>` on its stdin, bypassing `serve/server.py`) produces drafts normally: `DONE 64 16 132.3 431.5 length 43 44` (43 of 44 accepted) and `DONE 256 16 117.8 1631.6 length 167 176` (167 of 176, ~157 tok/s). The cause is that the server fills in the model card's sampling when a request names none, and the q36 engine only drafts for a strictly greedy request. In `serve/server.py`, `MODEL_CARD_SAMPLING["qwen35moe"]` is `{"thinking": {"temperature": 1.0, "top_p": 0.95, "top_k": 20, "presence_penalty": 1.5}, "instruct": {...}}`; in `src/qwen35/q36_engine.cu:3584` the door is `const bool spec = E.mtp_d > 0 && !smp.needs_logits() && !adm;` and `needs_logits() = temperature > 0 || repeat != 1 || freq != 0 || present != 0` (line 3013). A plain OpenAI request (`{"messages": [...], "max_tokens": 64}`, no sampling fields) therefore reaches the engine as `GEN 64 temperature=1.0 top_p=0.95 top_k=20 penalty_present=1.5 penalty_last_n=64 <ids>`, and `spec` is false for every window. Setups where MTP is the main reason to run this family lose the whole benefit without any error or warning. ### Smallest steps or command that reproduce it ``` # Strata 0.1.45 from source, Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf (753 tensors, 22 GB, 5.15 BPW), --max-context 81920 --mtp 2 # 1) a request that names no sampling, through the server: curl -s http://127.0.0.1:8081/v1/chat/completions -H 'Content-Type: application/json' \ -d '{"model":"...","messages":[{"role":"user","content":"1+1=?"}],"max_tokens":64}' # engine log: drafts accepted 0 of 0, ~74 tok/s # 2) the same shape, straight to the engine (engine/strata --serve ... on stdin): GEN 64 1,2,3,4,5,6,7,8,9,10,11,12,13,14 # DONE 64 16 132.3 431.5 length 43 44 (~150 tok/s) ``` To see the difference without reading the server sources, point the config's `exe` at a one-file pass-through proxy that logs stdin before forwarding; that is how the `GEN` line above was captured. ### Reproduction status Reproduced locally ### Strata version strata 0.1.45 (built from source; `engine/strata --version` reports `strata 0.1.45`) ### Graphics card, memory and system RTX 5060 Ti 16 GB · 30 GB RAM · Ubuntu 24.04, Linux 7.0.0-38 ### Model, size and settings Qwen3.6-35B-A3B-UD-Q4_K_XL · UD-Q4_K_XL (Unsloth Dynamic, 22 GB, 753 tensors, 5.15 BPW) · context 81920 · --mtp 2 · --prefill auto. The GGUF is an upstream file with a LoRA merged back in; its tensor types were restored to the base file's per-tensor types and it loads normally. ### Logs ``` # straight to the engine (drafting on) DONE 64 16 132.3 431.5 length 43 44 0 0 0 0 0 0.0 16 0 DONE 256 16 117.8 1631.6 length 167 176 0 0 0 0 0 0.0 16 0 # through serve/server.py, request with no sampling fields (drafting off) GEN 64 temperature=1.0 top_p=0.95 top_k=20 penalty_present=1.5 penalty_last_n=64 248045,846,198,... strata serve: session 0: prompt 14 tokens = 0 reused + 14 read in 174 ms (80.5 tok/s), 64 generated in 870 ms (73.6 tok/s), drafts accepted 0 of 0 (length) # the engine's own view while the block is loaded strata-q36: context 81920 cells, prompt chunk 2048, MTP block loaded, 4.81 GiB of VRAM free strata-q36: warmed up in 0.9 s (one prompt chunk, a decode step, a speculative step) ``` ### Workaround that works Put a `sampling` block in the run config so it overrides the model card's set: ```json "sampling": { "temperature": 0, "top_p": 1.0, "presence_penalty": 0 } ``` `top_k` must be left out (the config validation accepts 1..64 only). With that in place, drafts come back on the same machine and model: code-heavy 300-token output went from ~88 to 104 tok/s at `--mtp 2` (187/224 drafts accepted) and 113 tok/s at `--mtp 4` (221/320); a 256-token chat answer went from ~77 to 95 tok/s (62/128). ### What would help (one of these) 1. Say it: log one line when MTP is loaded but the resolved sampling rules out drafting (`drafts disabled: temperature 1.0`), instead of leaving the user to discover it from `0 of 0`. 2. Prefer drafting: when `--mtp N` is given, keep the request greedy unless the client asked for sampling itself, or document that MTP requires `temperature=0` with no penalties and that the model-card set turns it off. 3. A middle ground: a `--mtp-greedy` or config switch that drops the model-card defaults when MTP is on, keeping them for the plain path. Happy to test a patch on a 16 GB and a 32 GB card and report the numbers.
Author
Owner

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

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Area".
  • Fill in "Desktop app, Terminal or source?".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6283450651 --> @github-actions[bot] commented on GitHub (Oct 20, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Area". - [ ] Fill in "Desktop app, Terminal or source?". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

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

Thanks, this follows the format now.

<!-- gh-comment-id:6283480200 --> @github-actions[bot] commented on GitHub (Oct 20, 2026): Thanks, this follows the format now.
Author
Owner

@Bunkmil commented on GitHub (Oct 22, 2026):

An independent confirmation from a third machine: a Radeon 890M (gfx1150, Strix Point, 61 GB of unified memory, CachyOS, Linux 7.2, HIP), engine 0.1.47 built from source at 011c9e60, Qwen3.6-35B-A3B UD-Q4_K_XL, 32768 context, --mtp 2.

Same signature as above: with the 0.2.2 server as shipped, a bare temperature 0 request (thinking off) is not greedy — drafts accepted 0 of 0, 14.7 tok/s. Same 60-token prompt, max_tokens 220, thinking off:

request decode drafts
nothing but temperature 0 14.7 / 16.1 tok/s 0 / 0
temperature 0 + presence_penalty 0, frequency_penalty 0, repetition_penalty 1.0 12.6 / 13.1 tok/s 127 / 184 accepted (69%)
... after moving the merge out of Service._run (below) 36.3 / 36.8 tok/s 127 / 184 (69%)
... same, top_p 1.0 top_k 0 42.9 tok/s 95 / 108 (88%)

The second row is the telling one: the drafts run and are accepted at 69%, so the engine speculates correctly — the request simply never qualified. Its decode rate only looks lower because the drafted tokens commit against the same 220-token budget.

Two things that may help whichever fix lands:

  1. The card penalty costs the speculation to the qwen35moe path only. On the same box, Qwen3.8-Flash-Next IQ3_XXS speculates with the card's presence_penalty 1.5 in place (103 of 203 drafts at temperature 0, 15.5 tok/s). Only src/qwen35/q36_engine.cu gates on needs_logits() being false, so the impact is model-family specific even though the merge is not.
  2. The sampling workaround has a price. "sampling": {"presence_penalty": 0} in the run config works today, but the config block also wins for sampled requests, which then lose the card's anti-loop penalty. A server-side fix is the right one.

A third implementation of the same fix exists in a local branch (serve-card-penalties-temperature-0, commit dc3e409e, 2 files, +33/-5, adding test_temperature_zero_drops_the_card_penalties): the merge moves into a module-level sampling_for_request(), which drops the two penalties when the request asks for temperature 0. It is smaller than #3295 (model_card_sampling(..., greedy=...) + asks_greedy(), which also covers /props) and than #3676 (merge_sampling plus a note), so I would rather see one of those two land than open a fourth PR.

Validation of that local branch: serve/test_model_card_sampling.py 7 tests pass, including the new one; the full serve suite has the same 3 failures (keepawake, the portable lifeline watcher, GpuChoice.test_hip_ordinal) on a pristine worktree of the parent commit. Not run: CUDA or SYCL builds, and no Flash-Next comparison (the change is Python only).

<!-- gh-comment-id:6341062209 --> @Bunkmil commented on GitHub (Oct 22, 2026): An independent confirmation from a third machine: a Radeon 890M (gfx1150, Strix Point, 61 GB of unified memory, CachyOS, Linux 7.2, HIP), engine 0.1.47 built from source at `011c9e60`, Qwen3.6-35B-A3B UD-Q4_K_XL, 32768 context, `--mtp 2`. Same signature as above: with the 0.2.2 server as shipped, a bare `temperature 0` request (thinking off) is not greedy — `drafts accepted 0 of 0`, 14.7 tok/s. Same 60-token prompt, `max_tokens 220`, thinking off: | request | decode | drafts | | --- | --- | --- | | nothing but `temperature 0` | 14.7 / 16.1 tok/s | 0 / 0 | | `temperature 0` + `presence_penalty 0`, `frequency_penalty 0`, `repetition_penalty 1.0` | 12.6 / 13.1 tok/s | 127 / 184 accepted (69%) | | ... after moving the merge out of `Service._run` (below) | 36.3 / 36.8 tok/s | 127 / 184 (69%) | | ... same, `top_p 1.0 top_k 0` | 42.9 tok/s | 95 / 108 (88%) | The second row is the telling one: the drafts run and are accepted at 69%, so the engine speculates correctly — the request simply never qualified. Its decode rate only looks lower because the drafted tokens commit against the same 220-token budget. Two things that may help whichever fix lands: 1. **The card penalty costs the speculation to the qwen35moe path only.** On the same box, Qwen3.8-Flash-Next IQ3_XXS speculates with the card's `presence_penalty 1.5` in place (103 of 203 drafts at `temperature 0`, 15.5 tok/s). Only `src/qwen35/q36_engine.cu` gates on `needs_logits()` being false, so the impact is model-family specific even though the merge is not. 2. **The `sampling` workaround has a price.** `"sampling": {"presence_penalty": 0}` in the run config works today, but the config block also wins for sampled requests, which then lose the card's anti-loop penalty. A server-side fix is the right one. A third implementation of the same fix exists in a local branch (`serve-card-penalties-temperature-0`, commit `dc3e409e`, 2 files, +33/-5, adding `test_temperature_zero_drops_the_card_penalties`): the merge moves into a module-level `sampling_for_request()`, which drops the two penalties when the request asks for temperature 0. It is **smaller** than #3295 (`model_card_sampling(..., greedy=...)` + `asks_greedy()`, which also covers `/props`) and than #3676 (`merge_sampling` plus a note), so I would rather see one of those two land than open a fourth PR. Validation of that local branch: `serve/test_model_card_sampling.py` 7 tests pass, including the new one; the full `serve` suite has the same 3 failures (keepawake, the portable lifeline watcher, `GpuChoice.test_hip_ordinal`) on a pristine worktree of the parent commit. Not run: CUDA or SYCL builds, and no Flash-Next comparison (the change is Python only).
Author
Owner

@schmittcn commented on GitHub (Oct 24, 2026):

#3773 (opt-in STRATA_Q36_MTP_SAMPLED=1) makes these requests draft. A HIP / gfx1030 run of it is in the comments of
#3773: sampled decode +16 to +48% per prompt at a 16K window, and the same text for the same seed with fixed slots.

<!-- gh-comment-id:6380799316 --> @schmittcn commented on GitHub (Oct 24, 2026): #3773 (opt-in `STRATA_Q36_MTP_SAMPLED=1`) makes these requests draft. A HIP / gfx1030 run of it is in the comments of #3773: sampled decode +16 to +48% per prompt at a 16K window, and the same text for the same seed with fixed slots.
Author
Owner

@sarge18 commented on GitHub (Nov 5, 2026):

Still present in 0.2.10 (engine 0.1.56 linux-x86_64-cuda-cuda12, the signed package), on a different card class: Tesla P40 (sm_61), Qwen3.6-35B-A3B UD-Q4_K_XL, --mtp 2, Linux.

A greedy request (temperature 0, top_k 1) that does not name the penalties goes through with the card's presence_penalty 1.5. Every request then logs drafts accepted 0 of 0, and decode stays at 48–50 tok/s. Sending presence_penalty 0, frequency_penalty 0, repetition_penalty 1 explicitly brings drafting back: 124 of 130 accepted on the same three prompts, and 89% over a 69-task suite, with decode at 67 tok/s on a short prompt.

The same default also applies to the generic Flash-Next path. There it does not switch drafting off, but it does make a "temperature 0" request penalised, so its output is not greedy. A client that wants greedy output from Strata 0.2.x has to send all three fields; leaving them out does not mean "off".

Measured with the help of an AI assistant (Claude).

<!-- gh-comment-id:6649121636 --> @sarge18 commented on GitHub (Nov 5, 2026): Still present in **0.2.10** (engine `0.1.56 linux-x86_64-cuda-cuda12`, the signed package), on a different card class: **Tesla P40 (sm_61)**, Qwen3.6-35B-A3B UD-Q4_K_XL, `--mtp 2`, Linux. A greedy request (`temperature 0, top_k 1`) that does not name the penalties goes through with the card's `presence_penalty 1.5`. Every request then logs `drafts accepted 0 of 0`, and decode stays at 48–50 tok/s. Sending `presence_penalty 0, frequency_penalty 0, repetition_penalty 1` explicitly brings drafting back: 124 of 130 accepted on the same three prompts, and **89% over a 69-task suite**, with decode at 67 tok/s on a short prompt. The same default also applies to the generic Flash-Next path. There it does not switch drafting off, but it does make a "temperature 0" request penalised, so its output is not greedy. A client that wants greedy output from Strata 0.2.x has to send all three fields; leaving them out does not mean "off". *Measured with the help of an AI assistant (Claude).*
Author
Owner

@schmittcn commented on GitHub (Nov 7, 2026):

sarge18's comment (0.2.10, P40) adds one point the issue text doesn't cover yet: the model-card default also reaches the generic Flash-Next path. There it doesn't switch drafting off, but a temperature 0 request that doesn't name the penalties still runs with presence_penalty 1.5, so its output isn't greedy. A client that wants greedy output from Strata 0.2.x has to send presence_penalty 0, frequency_penalty 0 and repetition_penalty 1 explicitly; leaving them out doesn't mean "off". Maybe worth adding to the description, since the bug isn't limited to MTP.

<!-- gh-comment-id:6709488330 --> @schmittcn commented on GitHub (Nov 7, 2026): sarge18's comment (0.2.10, P40) adds one point the issue text doesn't cover yet: the model-card default also reaches the generic Flash-Next path. There it doesn't switch drafting off, but a `temperature 0` request that doesn't name the penalties still runs with `presence_penalty 1.5`, so its output isn't greedy. A client that wants greedy output from Strata 0.2.x has to send `presence_penalty 0`, `frequency_penalty 0` and `repetition_penalty 1` explicitly; leaving them out doesn't mean "off". Maybe worth adding to the description, since the bug isn't limited to MTP.
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#1361
No description provided.