Qwen4-35B-A3B-SM86-Fast
Qwen/Qwen4-35B-A3B prepared for fast single-stream decoding on two RTX 3090s (Ampere, sm_86) with vLLM 0.34.0 at tensor-parallel 2 and a 262,144-token context.
It starts from palmfuture/Qwen4-35B-A3B-GPTQ-Int4 (routed experts in GPTQ INT4) and changes two things:
- INT4 GPTQ
lm_head, recalibrated on 10.0M final-hidden-state rows captured while the model answered 8,469 prompts itself. - A 65,536-row draft head for the MTP drafter, so a draft token scores 26% of the vocabulary instead of all 248,320 rows. The rows are the most frequent tokens of the same self-generated text (8.0M tokens); verification still runs on the full target head, so decoding stays exact and only the acceptance rate moves.
With the cheaper draft step, two MTP draft tokens pay off (on the source checkpoint two tie and three lose).
Faster still with a DFlash2 draft: with quant-mind/Qwen4-35B-A3B-DFlash2-W4A16 instead of the MTP layer this checkpoint decodes about 21% faster again (see DFlash2).
It needs a patched vLLM. Stock vLLM 0.34.0 builds the Qwen4 lm_head without a
quantization config and has no pruned draft head; the patch is
reproduce/qwen4_exp-quant-head-draft-vocab.patch
(two files of vllm/models/qwen4_exp/nvidia). Those two files are identical in stock
0.34.0 and in the HyperQwen build, so the patch applies to both; every number below was
measured on the HyperQwen build, and stock 0.34.0 with the patch was not run.
Unofficial community build, not affiliated with Qwen / Alibaba, vLLM or palmfuture.
Measured
Two RTX 3090s capped at 270 W, PCIe P2P, no NVLink, TP2, fp8 KV cache, text only, one
stream. Runtime: HyperQwen de39ebdf (vLLM 0.34.0
plus its patch series) plus the patch above. "Source" is the palmfuture checkpoint with
one MTP draft token on the same runtime.
Decode on real prompts (6 code at temperature 1.0, the same 6 greedy, 3 Brazilian Portuguese and 3 English prose; 700 tokens each, warm), tok/s:
| Code T 1.0 | Code greedy | Prose PT-BR | Prose EN | Geomean | Drafts accepted | |
|---|---|---|---|---|---|---|
| Source, 1 draft token (two runs) | 181.0 / 177.4 | 191.1 / 191.7 | 176.0 / 173.2 | 173.1 / 168.9 | 180.2 / 177.6 | 81% / 79% |
| This build, 2 draft tokens | 221.4 | 243.6 | 214.3 | 211.3 | 222.3 | 62% |
That is about +24% over the source checkpoint. A paired run of the head changes alone (one draft token on both sides, 3 runs each) gave +13.9% at every context depth, with cold prefill and time to first token unchanged.
| Decode at a 224,132-token prompt | 197-214 tok/s (four runs of the harness preset) |
| Cold prefill, 224,132 tokens | about 7,400 tok/s, 30 s to first token |
| KV pool at TP2 | 714,434 tokens |
| Peak VRAM | 18.9 / 18.8 GiB at --gpu-memory-utilization 0.82 |
| GPU-resident weights | 11.78 GiB per card |
Quality against the source checkpoint:
| Source | This build | |
|---|---|---|
| Perplexity, 36,465 tokens of Go source | 2.2504 | 2.2545 (+0.18%) |
| Top-1 agreement with the source | 96.7% | |
| GSM8K, 200 questions, greedy | 197 | 198 |
| Verbatim copy of 10 source files, greedy | 9 | 9 (the same file fails on both) |
| Forced tool call with a shell-hostile command | 4/4 | 4/4 |
| Optional tool call, 10 needed / 10 not needed | 9 + 1 malformed / 10 | 10 / 10 |
DFlash2
The same checkpoint with a DFlash2 drafter (7 draft tokens) instead of the native MTP layer, same rig and prompts, each DFlash2 arm twice and the MTP arm first and last:
| Speculation | Code T 1.0 | Code greedy | Prose PT-BR | Prose EN | Geomean |
|---|---|---|---|---|---|
| MTP, 2 draft tokens | 217.3 / 221.3 | 240.3 / 244.7 | 206.2 / 208.5 | 198.1 / 203.6 | 214.9 / 219.0 |
| DFlash2 W4A16 | 291.0 / 289.1 | 327.9 / 327.6 | 197.2 / 225.0 | 230.7 / 233.3 | 256.7 / 265.5 |
With it, three cold-prefill runs gave a median decode of 242 tok/s after a 12.6k-token
prompt and 256 after a 224k-token prompt, cold prefill 7,792 tok/s, peak 18.9 / 18.8 GiB
and a KV pool of 734,328 tokens. It needs a second patch,
reproduce/qwen4_exp-aux-hidden-states.patch,
--block-size 2304 and the drafter repository, whose card has the command, the gates and
the license note (the upstream drafter declares no license).
Serving
# once, in the environment that has vllm==0.34.0
patch -p1 -d "$(python -c 'import vllm, os; print(os.path.dirname(vllm.__file__))')" \
< reproduce/qwen4_exp-quant-head-draft-vocab.patch
CUDA_DEVICE_ORDER=PCI_BUS_ID PYTORCH_CUDA_ALLOC_CONF=expandable_segments:False \
vllm serve /path/to/Qwen4-35B-A3B-SM86-Fast --served-model-name qwen4-35b-a3b \
--tensor-parallel-size 2 --distributed-executor-backend mp --dtype bfloat16 \
--max-model-len 262144 --max-num-seqs 1 --max-num-batched-tokens 4096 \
--gpu-memory-utilization 0.82 --kv-cache-dtype fp8 --language-model-only \
--engram-config '{"disk_offload":true}' \
--speculative-config '{"method":"mtp","num_speculative_tokens":2,"index_share_for_mtp_iteration":true}' \
--enable-prefix-caching --enable-prompt-tokens-details \
--enable-auto-tool-choice --tool-call-parser qwen3_coder --reasoning-parser qwen3
- The boot log must show
Qwen4 MTP drafter uses a 65536-token draft headandUsing MARLIN WNA16 MoE backend.MTP_DRAFT_VOCAB=0falls back to the full head. expandable_segments:Falsegoes with vLLM's custom all-reduce at TP2; with--disable-custom-all-reduceleave the allocator at its default.- The 20B-parameter n-gram table (41 GB, BF16, unchanged) is read from the checkpoint
files at run time (
disk_offload); keep them on an NVMe. config.jsonuses theQwen4ExpForConditionalGeneration/qwen4_expnames that vLLM 0.34.0 knows, as the source checkpoint does.- Sampling comes from
generation_config.json(temperature 1.0, top-p 0.95, top-k 20).reasoning_efforttakesxhigh,high(default),lowandoff. - Agent clients send the OpenAI effort names, and the stock template answers HTTP 400 to
none,minimalandmedium.--chat-template chat_template.agents.jinjaserves a copy that maps them instead (nonetooff,minimaltolow,mediumtohigh,maxtoxhigh); nothing else in it differs.
What is in it
| Part | Format |
|---|---|
| Routed experts, 40 layers x 256 | GPTQ INT4, group 128, symmetric (from palmfuture, unchanged) |
lm_head | GPTQ INT4, group 128, symmetric (new) |
mtp.draft_lm_head, 65,536 rows | BF16 rows of the original head (new); ids in mtp_draft_vocab_ids.pt |
| N-gram table, attention, Gated DeltaNet, shared experts, routers, hyper-connections, token embedding, MTP layer, vision encoder | BF16, unchanged |
PROVENANCE.md has the recipe, every rejected arm, the gates and the
sha256 of the files. reproduce/ has the capture plugin, the head and
draft-head builders, the vocabulary builder and the benchmark and gate scripts.
Limits
- Tested only on two RTX 3090s at TP2, one stream, text only. The vision encoder is in the checkpoint and was not exercised.
- The draft vocabulary was counted on code, tool calls, reasoning and English and
Brazilian Portuguese prose. Text in other scripts will draft worse (never wrong):
rebuild the list with
reproduce/build_vocab.py, or setMTP_DRAFT_VOCAB=0. - After a successful tool result the model often issues a second command to check the outcome; the source checkpoint does the same.
- At temperature 0 two runs were not token-identical.
Credits
- Qwen/Qwen4-35B-A3B, Apache 2.0, revision
849378c8. - palmfuture/Qwen4-35B-A3B-GPTQ-Int4,
revision
47e73e1e: the INT4 routed experts and the checkpoint layout. - syv-ai/HyperQwen: the runtime patch series and the draft-vocabulary idea this build ports to Qwen4.