Skip to content

spec : MTP draft vocab subset for qwen4exp and shared MTP sidecars (rebase of #253) - #289

Merged
dzannotti merged 2 commits into
masterfrom
pr-253-rebase
Nov 13, 2026
Merged

dzannotti merged 2 commits into
masterfrom
pr-253-rebase

Conversation

@dzannotti

Copy link
Copy Markdown
Collaborator

Supersedes #253 by @Nathanw1014 (with the qwen4exp commit by @gaetan-puleo). Same two commits, rebased onto master c054baa. The authors of both commits are unchanged. The original branch does not allow maintainer edits, so the rebase lands from this branch.

What changed in the rebase

One conflict, in llama_model::mtp_draft_vocab_get (src/llama-model.cpp): master added an EXL3 guard (#201), and #253 adds LLM_ARCH_QWEN4EXP to the same condition. The resolution keeps both:

if ((arch != LLM_ARCH_QWEN35 && arch != LLM_ARCH_QWEN35MOE && arch != LLM_ARCH_QWEN4EXP) || hparams.n_layer_nextn == 0 ||
        layers[hparams.n_layer()].nextn.shared_head_head != nullptr || exl3.linears.count(out)) {

git range-diff against the #253 head shows no other change.

Verification on the rebased branch

The maintainer review of #253 (head ede6d5b) covers the code. These runs check that it still works on current master.

Qwen3.8-Flash-Next Gyro-M TQ2_0 with the shared MTP sidecar (mtp-Qwen3.8-Flash-Next-shared-Q4_K_M.gguf), --spec-type draft-mtp, -np 1 -c 8192 -b 1024 -ub 1024 -fa on -lm none -lzm on-direct, 256 greedy tokens, 2 rounds, flag off vs --spec-draft-mtp-vocab 94208, gfx1151:

Backend Prompt Off (t/s) On (t/s) Gain Output and draft counts
Vulkan code 54.6 60.1 +10.1% identical
Vulkan prose 41.0 45.1 +9.9% identical
Vulkan reasoning 49.6 54.6 +10.1% output and accepted identical; drafted 230 vs 228
ROCm code 43.4 47.2 +8.9% identical
ROCm prose 35.3 38.5 +9.2% identical
ROCm reasoning 47.0 51.0 +8.5% identical

The two rounds agree within 1%. The server log has no "ignored" warning, so the subset is active.

test-llama-archs -a qwen4exp passes on ROCm0 and CPU. It aborts on the Meta device with ggml-backend.cpp:844: GGML_ASSERT(reg) failed in llama_memory_hybrid_idx. Master c054baa aborts in the same place, so this is not from this change. It needs its own issue.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YKmjzcT1LTvKtbw9EzBVGE

gaetan-puleo and others added 2 commits November 13, 2026 22:09
--spec-draft-mtp-vocab was accepted for qwen35/qwen35moe only, so on a
qwen4exp MTP sidecar the flag was silently ignored and every drafted token
was scored against the full 248k-row Q6_K LM head.

Allow LLM_ARCH_QWEN4EXP in mtp_draft_vocab_get and add the row-subset head
branch to graph_mtp, mirroring qwen35moe: score build_lora_mm on the runtime
subset (rows copied from the existing head at load - no file or weight change)
and scatter its logits into a full-vocab -inf row, so token ids and the
verification path stay unchanged.

Measured on Qwen3.8-Flash-Next UD-IQ4_XS + mtp-...-Q4_K_M sidecar, 128
greedy tokens, same-session A/B: 38.0 -> 41.5 t/s at N=65536 (+8%), identical
output and acceptance. N=131072 is slower than the control; N=32768/16384 are
about equal with a small acceptance loss. With the subset the draft phase is
340 ms of ~3.4 s and the target verify is the remainder.
A shared qwen4exp MTP sidecar (nextn_shared_target_tensors, e.g. Unsloth's
mtp-Qwen3.8-Flash-Next-shared-*.gguf) has no output.weight: graph_mtp borrows
the target's LM head through ctx_other. Two places made --spec-draft-mtp-vocab
a silent no-op on these files:

- llama_model::mtp_draft_vocab_get() returned nullptr when the draft had no
  output tensor. It now takes the subset rows from the target's LM head
  (shape checked) and warns when there is neither a head nor a target.
- the qwen4exp MTP graph used the subset only when head_w == model.output.
  It now uses it whenever the block scores with the model LM head, own or
  borrowed (not with a shared_head_head), and sizes the -inf row from head_w.

Assisted-by: Claude Opus 5.5
@dzannotti dzannotti added model risk:medium Risk: medium verified The claims were reproduced. labels Nov 13, 2026
@dzannotti
dzannotti merged commit c495f90 into master Nov 13, 2026
8 of 11 checks passed
@dzannotti
dzannotti deleted the pr-253-rebase branch November 13, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model risk:medium Risk: medium verified The claims were reproduced.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants