Repository navigation
feat(qwen4exp): MTP speculative decoding (stacked on #774) - #808
Merged
Merged
Conversation
Contributor
|
Pushed Checked on a Ryzen AI Max + R9700 box:
#809 and #810 sit on the previous #808 head, so they need the same update. 🤖 Generated with Claude Code |
Squashed onto main after Luce-Org#774's squash-merge. Per-commit history: dusterbloom/lucebox-hub branch history/qwen4exp-mtp-20261008. Commits: - perf(ggml): fuse QSA block sorting and cell expansion - perf(qwen4exp): use fused QSA cell IDs after top-k - docs(qwen4exp): plan stable bucketed QSA decode - perf(qwen4exp): reuse QSA decode graphs between pooling steps - perf(qwen4exp): reuse QSA decode graphs across complete KV buckets - feat(qwen4exp): MTP speculative decoding on the QSA speed branch - feat(qwen4exp): draft up to four MTP tokens per step - fix(qwen4exp): keep MTP verify batch-invariant up to eight rows - feat(qwen4exp): adaptive MTP draft width through the shared spec-width policy - fix(qwen4exp): clear MTP sidecar pointers on teardown and load failure - docs(qwen4exp): drop the obsolete delivery footer from the MTP handoff - fix(qwen4exp): validate every MTP sidecar tensor shape before graph build - refactor(qwen4exp): simplify the PLE tail helper to a slice of seq - chore(qwen4exp): delete the unused chat() wrapper in forward_diff script - refactor(qwen4exp): inline the two-field stable_kv_span wrapper - refactor(qwen4exp): drop the temporary upload_layers pointer vector - perf(qwen4exp): fill only the MTP layer's K/V during prompt prefill - perf(qwen4exp): fill the MTP K/V inside the trunk prefill graph - fix(qwen4exp): wait for pending rollback copies before resetting state - perf(qwen4exp): cheaper MTP drafts and up to seven of them - fix(qwen4exp): keep the adaptive MTP width stable - fix(server): accept qwen4exp fixed verify widths up to eight - docs(qwen4exp): describe the seven-draft adaptive MTP in the guide - test(qwen4exp): accept fixed verify widths up to eight in the gate test - test(qwen4exp): prefill the MTP rollback check in chunks - fix(qwen4exp): adapt MTP reference tests to current graph APIs - test(qwen4exp): check MTP profile restore against generic mode - fix(ggml-cuda): guard HIP-only MMB teardown - feat(qwen4exp): Qwen3.8-Flash-Next backend — parity, prefill/decode perf (Luce-Org#774) - refactor(qwen4exp): MTP on the cleaned-up backend from Luce-Org#774
dusterbloom
force-pushed
the
feat/qwen4exp-mtp
branch
from
October 8, 2026 09:03
d54df4b to
ef99382
Compare
davide221
added a commit
that referenced
this pull request
Oct 8, 2026
feat(qwen4exp): reuse cached prompt prefixes across requests (stacked on #808)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #774 has merged. This PR now contains the MTP delta against
main. Review only the MTP work: dusterbloom/lucebox-hub@c320db9...d54df4bWhat
Speculative decoding for Qwen3.8-Flash-Next with the model's own MTP block. The single MTP layer is reused to chain up to seven drafts per step, and the trunk verifies them in one batched forward.
MTP/mtp-*.ggufnext to the model) is found automatically. Without it, decode runs without MTP.--verify-width 0(default): adaptive width, up to k=7 drafts, from per-depth acceptance and a per-request cycle-cost fit.--verify-width 1: MTP off.--verify-width 2..8: fixed k=1..7.Exactness
A draft is accepted only if it equals the token the trunk samples, so output is byte-identical to MTP off for the same seed and the same prefill chunk size. Rollback restores the KV/recurrent state bit-exactly. (Automatic chunk sizing is chosen from free memory, and loading the MTP sidecar can change it at some context sizes, e.g. 8192 vs 4096 rows at
--max-ctx 81920; pin--chunkwhen comparing MTP on and off. At the recommended--max-ctx 131072both use 4096.)test_qwen4exp_mtp: 4,236 acceptance/rollback cases plus config and adaptive policy.test_qwen4exp_mtp_dispatch: 21 cases.test_feature_gate: widths 0..8 accepted, -1/9 refused.smoke_qwen4exp_forward, MTP on vs off, k=1..4 at S=16 and S=2200:tokens_identical=1 logits_identical=1, and every rollback case iscache_and_logits_identical=1.--chunk 2048); server text identical MTP on vs off on a 69,857-token prompt with--chunk 4096pinned (21.0 vs 25.9 tok/s decode).Speed (gfx1151, UD-Q4_K_XL)
Decode tok/s at temp 0, fresh server per run, nothing prefix-cached, identical text in every arm; medians of 3:
On the counting cell the adaptive width settles at seven drafts (7.74 tokens per cycle, 445/446 accepted).
Prefill
MTP costs 4-6% of prefill: the prompt's MTP K/V is filled inside the trunk's chunk graph (no separate MTP graphs, no second embedding upload, no host round-trip of the hidden rows). With #774's memory-sized chunks (7168 rows MTP off, 4864 with MTP at 262K; same session, medians of 2):
Guide:
server/docs/QWEN4EXP.md(MTP section).2026-10-07 restack validation. PR #774 is merged as
c320db9a. The cumulative #810 source ata93d8bef, including the material #808 refactor atd54df4bcand adapted #809/#810, was freshly built for gfx1151 and passed the HIP/model gate (sha256:93210dffb2442f36a841a066f10eb298898a84e389b94c55f2993bcde61e66f1): actual DS4 fused GPU fixture, MTP host/dispatch contracts, Q2_0 differential, MMID, trim/recompute, park/unpark, plain/split/stable forward, all-width MTP rollback, batched and four-slot sequence/HTTP serving, and both model-backed prefix-cache tests. The throughput tables above retain their original measurement attribution.For #808, this is cumulative stack evidence; its MTP-only source boundary is the compare link above.