Skip to content
プロジェクト

概要

Qwen4-35B-A3B at about 2x the stock vLLM speed on one 48 GB GPU (RTX 6000 Ada): 139 -> 312 tok/s single stream, 2,264 tok/s at 64 streams. 4-bit at load time, DFlash2 and MTP speculative decoding, vLLM patches, recipes, raw benchmark logs.

AI・機械学習

この数値の測り方

計測したスター増加

24時間
履歴を収集中
7日間
履歴を収集中
15日間
履歴を収集中
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

qwen4-fast: Qwen4-35B-A3B on one 48 GB GPU, about twice the stock vLLM speed

Decode tok/s on one RTX 6000 Ada, qwen4-fast against stock vLLM: 313 vs 140 for one user with sampling, 336 vs 153 greedy, 815 vs 270 at 8 users

Qwen4-35B-A3B served with vLLM on one RTX 6000 Ada (48 GB): 139-142 tok/s with the stock recipe, 312-314 tok/s for one user, 2,264 tok/s summed over 64 concurrent users. The main model comes from the official FP8 checkpoint and is requantized to 4-bit when the server loads it. The cost is about 3% higher perplexity, a patched vLLM image for the two fastest recipes, and output that is not bit-exact.

This repository holds the launch recipes, a patch series for vLLM, the benchmark scripts, and the raw output of every run.

one RTX 6000 Ada, 300 W, 32k context stock recipe recipes/single-user.env recipes/multi-user.env
1 stream, default sampling (decode rate) 139-142 tok/s 312-314 tok/s (2.2x) 263-270 tok/s (1.9x)
1 stream, greedy (decode rate) 153 tok/s 336-362 tok/s 285-291 tok/s
1 stream, slowest and fastest of the 8 prompts (default sampling, pass 2) 122 and 161 tok/s 233 and 509 tok/s 227 and 304 tok/s
8 streams, end-to-end sum 270 tok/s (requests queue, see below) 815 tok/s 804 tok/s
16 / 32 / 64 streams, end-to-end sum not measured not measured 1,281 / 1,865 / 2,264 tok/s
weights on the GPU ("Model loading took") 37.2 GiB 23.1 GiB, drafter included 21.6 GiB
KV cache pool 64k tokens 431k tokens 884k tokens
perplexity, 22.6k-token test set 7.195 7.394 (+2.8%) 7.407 (+3.0%)
perplexity past token 2,048 4.916 5.069 (+3.1%) 5.075 (+3.2%)
GSM8K, 200 questions 98.5% 98.5% 97.0%
extra download none drafter, about 0.8 GB none
vLLM image stock patched patched

Sources: results/stock-fp8-mtp3-ctx32k, results/i03-dflash2-all-full, results/i04-mtp-schedule-all-full; the stock long-context perplexity is from results/r01-ref-fp8-mtp2-drafthead4bit (same weights). How the numbers are chosen is in How to read the numbers.

What to keep in mind before reading further:

  • One card, one day. Everything was measured on 2026-12-04 on one RTX 6000 Ada that other processes shared: vLLM saw 43.86 of 47.45 GiB free at start-up in every run, and nvidia-smi showed 3,142 MiB held by other processes where that was recorded (the field report and the memory traces). No other GPU has been measured, and no 24 GB card: the 24 GB recipes peak at 23.2 GiB on this one.
  • Against tqLLM 2.0.0 on the same card, thinking off: 385 against 272 tok/s greedy, 357 against 155 tok/s with sampling, 707 against 160 tok/s at 8 streams; tqLLM uses less than half the memory and crashed under the tool-calling battery (details).
  • The stock comparison stops at 8 streams. The stock recipe was run with a 32k context and its default request slots. Its KV pool then holds 1.96 full-length requests, so at 4 and 8 streams requests wait in the queue (mean time to first token 2.7 s and 9.3 s) and the sum stays at 267-270 tok/s. A smaller context limit or an idle card might lift that; neither was tried. The stock recipe was not run at 16-64 streams.
  • Quality. Perplexity is 2.8-3.0% higher than with the official weights on short windows and 3.1-3.2% higher past 2,048 tokens. GSM8K moved by 1.5 points between two runs of the same official weights (98.5% and 97.0%), so it only says "not broken".
  • Not bit-exact. Greedy output of the 4-bit configurations differs between restarts (details).
  • The two fastest recipes were measured with the patch series mounted over the stock image, not with the image the Dockerfile builds. The Dockerfile applies the same series; what ran through the built image is one screening run (results/j01-24gb-patched-image) and the two 24 GB fit checks (n01, n02).

The approach is HyperQwen's, ported to Qwen4. This is an independent project, not affiliated with syv-ai, the vLLM project or Alibaba.

Quick start

Needs Docker with the NVIDIA runtime, and on the host python3 (standard library only), curl and nvidia-smi. The only card measured has compute capability 8.9 and 48 GB.

git clone https://github.com/extra2byte/qwen4-fast && cd qwen4-fast
python3 prepare/hf_fetch.py Qwen/Qwen4-35B-A3B-FP8 models/Qwen4-35B-A3B-FP8 --verify   # about 60 GB

# No patch: the stock vllm/vllm-openai:qwen4 image, 4-bit at load time, 229-241 tok/s for one user
scripts/serve_recipe.sh recipes/fast-4bit.env

curl http://127.0.0.1:18040/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"Qwen/Qwen4-35B-A3B","messages":[{"role":"user","content":"Hello"}]}'
scripts/serve_recipe.sh recipes/fast-4bit.env stop

The server speaks the OpenAI API and is published on localhost only. Requests may carry any OpenAI reasoning_effort: medium (the default of many clients) becomes high, Qwen4's own default, and minimal, max and none become low, xhigh and off; without that mapping the server answers them with a 400. It keeps compiled kernels in a cache/ directory next to models/ (set CACHE_DIR to move it); the container writes there as root.

The two fastest recipes and the two 24 GB recipes need the patched image and the calibrated head:

docker build -t qwen4-fast:dev .        # the stock image plus patches/series
prepare/calibrate_head.sh               # writes models/q4fast/lm_head_int4_gptq.safetensors, on the CPU, about half a minute
scripts/serve_recipe.sh recipes/multi-user.env

# single-user.env also needs the drafter (a second, small model):
python3 prepare/hf_fetch.py RadixArk/Qwen4-35B-A3B-Dflash2 models/Qwen4-35B-A3B-Dflash2 --verify
scripts/serve_recipe.sh recipes/single-user.env

# on a 24 GB card: does it fit? Writes a report with the memory peak (see "24 GB cards")
bench/fit_check.sh recipes/fast-24gb.env
recipe image what it is one stream, default / greedy
stock.env stock official FP8 checkpoint, MTP-3 139-142 / 153
fast-flags.env stock MTP-2, 4-bit draft head, 4-bit trunk; experts stay FP8 207-208 / 223
fast-4bit.env stock the same plus 4-bit experts 229-241 / 246-257
fast-4bit-head.env patched, pass IMAGE=qwen4-fast:dev the same plus an int4 output head, round to nearest 255-262 / 277-280
multi-user.env patched calibrated int4 head, MTP-2 up to 16 running requests and MTP-1 above, fused kernels, 64 request slots 263-270 / 285-291
single-user.env patched calibrated int4 head, DFlash2 drafter with a 4-bit MLP, fused kernels 312-314 / 336-362
fast-24gb.env patched for 24 GB cards, images included: calibrated int4 head, MTP-2 with a 4-bit drafter, fused kernels, 16k context, 2 slots, 0.6 GiB KV pool. Peak 23.2 GiB on the 48 GB card; not yet run on a 24 GB card 270-274 / 290-291 (n03: perplexity 7.413, GSM8K 97.5%)
fast-24gb-text.env patched the same for text only: 32k context, 4 slots, 1.1 GiB KV pool. Peak 23.2 GiB on the 48 GB card; not yet run on a 24 GB card 274 / 290, one screening run at 16k context with a larger pool (m01)

prepare/calibrate_head.sh builds the calibrated head on the CPU from the Hessian in calib/ (see GPTQ). Its docker run command, run with the checkpoint mounted read-only, took 27 s on our box and wrote the same three tensors, value for value, as the head that was measured (which had been built on the GPU, log); only the order of the file's metadata differs. No log of that check is under results/.

The base image is the tag vllm/vllm-openai:qwen4. The series is cut against vLLM 0.1.dev26393+gf247de72b and the build stops if the tag has moved to another version; the image used here had the digest sha256:63a160daa7b2 (report).

Terms

  • MTP (multi-token prediction): a small draft head that ships inside the Qwen4 checkpoint. After each verified token it proposes N more (MTP-1, MTP-2, MTP-3); the main model checks them in its next pass and keeps the part that agrees. The stock vLLM recipe uses MTP-3.
  • DFlash2: a separate drafter model, RadixArk/Qwen4-35B-A3B-Dflash2 (5 layers, about 0.8 GB). It reads hidden states of five layers of the main model and proposes a block of 7 tokens per step. The server needs --block-size 2304 to start with it, which single-user.env sets.
  • Tokens per step: tokens emitted per pass of the main model. Without speculation it is 1.
  • sm_89: CUDA compute capability 8.9, the Ada generation (RTX 6000 Ada, RTX 4090, L40S). It has no native 4-bit floating-point arithmetic.
  • NVFP4, MXFP4: two 4-bit floating-point weight formats with a shared scale per small block of values. Here they are only storage formats for weights: vLLM converts the weights when it loads them, and on sm_89 runs them through Marlin, a matrix kernel that unpacks 4-bit weights while it multiplies. Activations stay 16-bit.
  • int4 head: the output layer (lm_head, 248,320 x 2,048) stored as 4-bit integers with one scale and zero point per 32 input channels. vLLM can do this at load time by rounding to nearest.
  • GPTQ: a quantization method that, instead of rounding each weight to the nearest step, chooses the rounding that keeps the layer's output closest on real inputs. It needs the second moment of those inputs (a 2,048 x 2,048 "Hessian"), collected here from 339,968 hidden states of the model's own generation.
  • Hyper-connections: the modules that mix Qwen4's residual streams, 81 per pass, each with a small down and up projection.
  • Decode rate: streams x 1000 / mean time per output token. It leaves out the time to first token. End-to-end rate: output tokens divided by wall time, first token included.
  • Screening run: one discarded pass and one kept pass at one stream. A full run adds the concurrency ladder and a third pass that repeats the one-stream measurement.

How it works

The official FP8 checkpoint quantizes the routed experts and leaves the rest in 16-bit. Of the 5.64 GB one decode pass reads, 4.63 GB is 16-bit (audit, prepare/audit_weights.py). The work here is to shrink what a step reads, to launch fewer kernels per step, and to get more tokens out of each step.

  1. Fewer drafts. MTP-2 instead of the recipe's MTP-3, and a 4-bit copy of the head for the drafter. Two flags on the stock image: 139-142 becomes 174-175 tok/s.
  2. 4-bit trunk at load time. The Gated DeltaNet and attention projections become NVFP4 weights through one --quantization-config flag: 207-208 tok/s (recipes/fast-flags.env).
  3. 4-bit experts at load time. The FP8 experts are requantized to MXFP4: 229-241 tok/s, and the weights drop from 35.7 to 22.6 GiB (recipes/fast-4bit.env). Up to here no patch is needed.
  4. int4 output head. Two small patches let the load-time int4 format apply to Qwen4's lm_head on sm_89: 255-262 tok/s. Rounding to nearest costs perplexity (7.345 to 7.463); a GPTQ-calibrated head takes about half of that back (7.403) at the same speed.
  5. Speculation by load. For one user the DFlash2 drafter yields 2.7-3.2 tokens per step against about 2.0-2.2 for MTP-2. For many users a schedule runs MTP-2 up to 16 running requests and MTP-1 above.
  6. Fused hyper-connection kernels. vLLM fuses these kernels on newer GPUs only; a patch enables two of them on sm_89. Measured +7% without speculation and +4-9% with MTP-2.

Results

How to read the numbers

One rule for every number in this repository's documents:

  • Protocol. HyperQwen's 8 prompts, 1,024 output tokens each, thinking on (bench/q4bench.py, scripts/run_experiment.sh). Pass 1 after a server start includes kernel compilation and is discarded. Passes 2 and 3 are kept.
  • One stream: the decode(C/meanTPOT) value of the kept passes in results/<run>/bench.txt. A configuration measured in several runs is quoted as the range over all kept passes of all those runs.
  • Several streams: the end-to-end rate e2e= of the kept row, one pass per level. The decode rate is never used there: it ignores queueing.
  • Quality is from quality.txt and longctx.txt of the run, memory from the Model loading took and GPU KV cache size lines of its server.log.
  • Context limit is 32,768 tokens unless a row says otherwise (MAX_LEN in the run's env.txt).
  • Spread. Kept passes of one configuration differ by up to 5% at default sampling (228.8 and 240.9 in p06) and 7% greedy (336.4 and 361.6 in i03). Differences smaller than that between two rows are not established.
  • "Patched tree" in an env.txt means the series in patches/ was mounted over the stock image.

One stream

Decode rate in tok/s, default sampling / greedy. "s" marks a screening run (one kept pass), "f" a full run (two kept passes).

# configuration default greedy tokens per step runs
official FP8 weights
1 no speculation 113.8 115.1 1 q01 s
2 MTP-3: the stock recipe 139.2-142.1 153.1-153.2 2.13-2.17 / 2.34 stock f
3 MTP-2 156.3 161.8 2.12 / 2.20 q03 s
4 MTP-3, 4-bit draft head 170.5 178.7 2.19 / 2.31 q04 s
5 MTP-2, 4-bit draft head 173.6-174.9 183.1-183.8 2.06-2.09 / 2.19-2.20 q05 s, r01 s
4-bit trunk (row 5 plus one flag: fast-flags.env)
6 MTP-2, 4-bit draft head 206.8-208.2 222.7-223.2 2.03-2.05 / 2.20-2.21 p03 s, p03b s
4-bit trunk and experts
7 no speculation 156.8-157.7 159.7-160.5 1 e01 f
8 MTP-2, 4-bit draft head: fast-4bit.env 228.8-240.9 246.1-257.1 1.99-2.09 / 2.14-2.23 p05 s, p06 f, field f
9 DFlash2 249.4-256.0 264.9-280.6 2.79-2.86 / 2.98-3.12 d01 s, e02 f
4-bit trunk and experts, int4 head, round to nearest
10 MTP-2: fast-4bit-head.env 255.1-262.0 277.5-280.4 2.01-2.05 / 2.20 p10 s, e03 f
11 DFlash2 289.1-299.6 317.6-326.4 2.74-2.83 / 3.00-3.10 d02 s, f01 f
4-bit trunk and experts, int4 head calibrated with GPTQ
12 no speculation 181.4-182.5 184.5-186.0 1 g01 f
13 MTP-1 248.6-250.8 262.6-264.7 1.70-1.71 / 1.80 g03 f
14 MTP-2 253.4-265.5 277.0-281.1 2.00-2.08 / 2.16-2.21 f04 s, g02 f
15 DFlash2, 4-bit drafter MLP 315.3 326.4 2.87 / 2.96 h03 s
the same, fused hyper-connection kernels on
16 no speculation 195.3 198.3 1 i01 s
17 MTP-2 275.5 292.6 2.06 / 2.19 i02 s
18 MTP-2 up to 16 requests, MTP-1 above: multi-user.env 262.6-270.2 285.4-291.0 2.03-2.04 / 2.18-2.22 i04 f
19 DFlash2, 4-bit drafter MLP: single-user.env 311.6-313.8 336.4-361.6 2.73-2.79 / 2.99-3.19 i03 f

What differs inside a row or between neighbours, where it is more than the heading says:

  • Row 5: r01 had the patched tree mounted, q05 not; the flags are the same.
  • Row 8: p06 ran with a 131k context and 64 request slots, field with 32k and 64 slots (footnote (c) under the next table) on the stock image, p05 with 32k and default slots.
  • Rows 12, 13, 14 (g01, g02, g03) and row 18 ran with --max-num-seqs 64; f04, i01 and i02 with the default.
  • Rows 8 and 10 differ in two things: the int4 target head, and the drafter sharing that head instead of its own NVFP4 copy.
  • Rows 11 and 15 differ in two things: the head is calibrated, and the drafter's MLP is 4-bit (patches/dflash2-cost-knobs.patch). They were not measured apart.
  • Rows 1-5 ran on the stock image except r01; rows 6-7 and 9-19 had the patched tree mounted, although rows 6-8 use no patched code path. In row 8 only p06 and field ran on the stock image itself.

Readings:

  • A third MTP draft does not pay on this card: 139-142 with MTP-3 against 156 with MTP-2 (rows 2 and 3). With a 4-bit draft head the two are 2-3% apart, inside the spread (rows 4 and 5).
  • MTP-1 against MTP-2 at one stream (rows 13 and 14): at default sampling the two are inside the spread (248.6-250.8 against 253.4-265.5). Greedy, MTP-2 is 5-7% ahead in every kept pass (277.0-281.1 against 262.6-264.7).
  • DFlash2 depends on the prompt far more than MTP does. In the kept pass of i03 at default sampling the 8 prompts run from 233 tok/s (a long article in Danish) to 509 (a summary that quotes its input); in i04 with MTP they run from 227 to 304.
  • With DFlash2 the fused kernels show no gain at default sampling (rows 15 and 19), and the greedy difference is inside the spread of row 19 itself.

Several streams

End-to-end rate in tok/s summed over the streams, default sampling, one kept pass per level. The 1-stream column is the pass-2 end-to-end value of the same run, so it is slightly lower than the decode rate above.

configuration 1 2 4 8 16 32 64 run
stock recipe 137.2 218.3 267.3 270.0 stock
4-bit, no speculation 156.1 260.0 448.9 688.8 e01
fast-4bit.env, 131k context, 64 slots 237.4 387.9 598.8 808.1 p06
fast-4bit.env, stock image, 64 slots (c) 226.7 1,198.0 1,667.6 1,986.2 field
fast-4bit-head.env (MTP-2) 252.2 411.5 652.4 902.5 e03
DFlash2, int4 head, round to nearest 282.7 433.8 595.1 782.5 f01
calibrated head, no speculation, 64 slots 180.0 1,094.1 1,564.0 2,113.6 g01
calibrated head, MTP-1, 64 slots 248.0 1,224.8 1,885.0 2,421.3 g03
calibrated head, MTP-2, 64 slots 250.3 1,290.0 1,701.5 2,172.2 g02
multi-user.env (64 slots) 258.6 431.1 625.6 803.8 1,280.6 1,864.9 2,263.6 i04
single-user.env 302.6 460.3 650.4 814.5 i03

Empty cells were not measured. Rows without "64 slots" ran with vLLM's default number of request slots.

(c) The 64 slots of the field run are from that run's env.txt, which is not in the committed folder; the committed report cuts the recipe line before EXTRA_ARGS.

  • MTP depth by load. With a fixed depth, MTP-2 is ahead at 16 streams (1,290 against 1,225) and MTP-1 at 32 and 64 (1,885 and 2,421 against 1,702 and 2,172), one pass each. multi-user.env switches at 16 running requests and lands within about 1% of the better fixed depth at 16 and 32 (0.7% and 1.1% below).
  • At 64 streams multi-user.env is 6.5% below fixed MTP-1 (2,264 against 2,421, one pass each). The two runs also differ in the fused kernels, which are on in i04 and off in g03; which of the two causes the gap was not measured. If you only ever serve 32 or more streams, fixed MTP-1 is the measured best.
  • At 8 streams multi-user.env measured 804 tok/s, with a mean time to first token of 1.2 s in that cohort, against 903 for MTP-2 with the round-to-nearest head and default slots (e03). One pass each; the cause was not looked into.
  • single-user.env was not measured above 8 streams. At 8 it is level with multi-user.env (815 against 804) and it has half the KV pool, so multi-user.env is the one to use for many users.
  • At 64 streams with multi-user.env each stream gets 41-82 tok/s and the mean time to first token is 0.8 s.
  • The 16/32/64 levels of p06 are left out: that ladder ran 8 streams at every level (what did not work).

Against tqLLM 2.0.0

tqLLM 2.0.0 (C++, its own GGUF formats) added Qwen4-35B-A3B on the same day. Both engines ran on this card with the same client, the same 8 prompts and 1,024 tokens each, thinking off (tqLLM's own measurement setting), pass 1 discarded. Sampling was set explicitly to the model's recommended values (temperature 1.0, top_p 0.95, top_k 20) on both, because tqLLM's server default is greedy (results/x01-vs-tqllm):

tqLLM, Qwen4-35B-A3B-TQT.gguf + built-in MTP + 40,960-token draft vocabulary, --qsa-from 4096 (its model card's command) tqLLM, unsloth UD-IQ4_XS, 8 slots, no drafter single-user.env (8 slots, 131k context)
1 stream, greedy 271.7 tok/s 250.6 385.2
1 stream, T=1.0 154.5 tok/s 93.2 357.2
8 streams, T=1.0, end-to-end sum not possible: MTP serves one slot 160.2 707.2
mean time to first token, 1 stream 70 ms 72 ms 47 ms
GSM8K, 200 questions, greedy 98.0% not run 96.5% (98.5% in i03)
tool-calling battery (below) the server crashed about two minutes in (CUDA illegal memory access in its expert cache, log); no score not run 92.8% (t01)
device memory (nvidia-smi, minus 3.1 GiB of other processes) 19.6 GiB not recorded 43.5 GiB (vLLM sizes its KV pool to the card)
  • Where tqLLM is ahead: memory and reach. It runs Qwen4 in under 20 GiB, runs 256k contexts on a 24 GB card, and runs on Macs, Windows, V100 and AMD cards; this repository needs Linux, Docker and an NVIDIA GPU, and its 24 GB recipes stop at 16k-32k context. Its TQT file reports a KL divergence of 0.058 against BF16, measured by tqLLM; the two engines' quality was compared here only through GSM8K.
  • Not measured: unsloth's separate MTP GGUF was refused by tqLLM ("MTP file's copy of output.weight differs from the trunk's"), so the IQ4_XS column has no drafter. One run each; tqLLM's greedy speed was measured with --qsa-from 4096, which its documentation calls an approximate path on CUDA.
  • Our single-stream numbers here are higher than the 312-314 / 336-362 tok/s at the top because thinking is off: answers draft better than reasoning text.

Memory

From each run's server.log. The KV pool is what vLLM had left on this card with 43.86 of 47.45 GiB free at start-up; it also depends on the number of request slots and on the speculation method.

configuration Model loading took KV pool, tokens run
stock recipe (MTP-3) 37.16 GiB 64,299 stock
MTP-2, 4-bit draft head 37.43 GiB 48,106 q05
+ 4-bit trunk 35.69 GiB 136,649 p03
+ 4-bit experts (fast-4bit.env) 22.55 GiB 810,833 p05
+ int4 head (fast-4bit-head.env) 21.61 GiB 859,637 p10
multi-user.env (64 slots) 21.61 GiB 884,038 i04
DFlash2, int4 head 23.38 GiB 423,071 f01
single-user.env 23.10 GiB 430,717 i03

The stock recipe does not start on this card with --max-model-len auto: 38.31 GiB of weights and non-torch memory, 1.26 GiB of activations and 2.8 GiB of CUDA graphs leave nothing for the KV cache (log). All stock numbers here use a 32k limit.

Quality

bench/quality.py: perplexity over 22,628 tokens (40 English windows from wikitext-2 and 40 windows of Python source) and 200 GSM8K questions. bench/longctx.py: perplexity over 22,462 tokens past position 2,048, and a planted line to retrieve from about 19.8k tokens of context, 15 trials. Percentages are against the official weights: 7.1948 from stock and, for the long-context column, 4.9157 from r01, the only official-weights run with that test.

weights speculation in the run PPL PPL past 2,048 needle GSM8K run
official FP8 MTP-3 7.1948 98.5% stock
official FP8 MTP-2 7.2015 4.9157 15/15 (a) 97.0% r01
+ 4-bit trunk MTP-2 7.2733 (+1.1%) 98.0% p03
+ 4-bit trunk MTP-2 7.2663 (+1.0%) 4.9901 (+1.5%) 14/15 (a) 98.0% p03b
+ 4-bit experts MTP-2 7.3449 (+2.1%) 5.0489 (+2.7%) 15/15 (a) 98.5% p05
+ int4 head, round to nearest MTP-2 7.4630 (+3.7%) 5.1145 (+4.0%) 15/15 97.5% p10
the same DFlash2 7.4535 (+3.6%) 5.1086 (+3.9%) 15/15 97.5% f01
+ int4 head, GPTQ MTP-2 7.4029 (+2.9%) 5.0624 (+3.0%) 15/15 99.0% f04
single-user.env DFlash2 7.3939 (+2.8%) 5.0692 (+3.1%) 15/15 98.5% i03
multi-user.env MTP schedule 7.4073 (+3.0%) 5.0746 (+3.2%) 15/15 97.0% i04

(a) These three runs used an earlier wording of the planted line. The one miss was a refusal: the answer mentions a suspected prompt injection. The line was reworded afterwards and refusals are now counted apart; the rows without (a) use the new wording, so the needle column is not one test throughout.

  • The same weights measured twice give 7.1948 and 7.2015, and 7.2733 and 7.2663: perplexity repeats to about 0.1%. The three GPTQ rows span 0.18% (7.3939 to 7.4073) and 0.24% past 2,048 tokens (5.0624 to 5.0746). That is about twice the repeat figure, from three runs, so no difference between them is established, and neither is their equality. Two of the three ran with the fused kernels on, whose outputs are not bit-identical to the unfused path.
  • The quality battery runs with the drafter on. That DFlash2 gives the same numbers as MTP-2 on the same weights (rows p10 and f01) is the check that its rollback works.
  • GSM8K ranges from 97.0% to 99.0% with no pattern; one question is 0.5 points.
  • The GPTQ gain is measured in-domain. The calibration prompts are GSM8K test questions 200-300, later parts of the same wikitext-2 file, the 8 benchmark prompts and 8 code tasks (prepare/build_draft_vocab.py). The quality battery uses questions 0-199 and the first part of that file. The slices do not overlap, but they come from the same sources, so the gain on unrelated text may be smaller. That was not measured.
  • No task benchmark beyond GSM8K was run.

Is greedy output reproducible?

Checked with bench/compare_outputs.py on the saved greedy texts of two runs (8 prompts, about 1,024 tokens each; "prefix" is the mean share of the text before the first difference).

pair identical prefix
official weights, stock image, two server starts: stock and q04 (MTP-3), q03 and q05 (MTP-2). Each pair differs in the draft head's precision only 8 of 8, both pairs 100%
official weights, same flags, stock image against patched tree: q05 and r01 2 of 8 29%
4-bit trunk, same configuration restarted: p03 and p03b 2 of 8 31%
4-bit trunk and experts, same weights and speculation in two runs: p05 and p06, p10 and e03, d01 and e02, d02 and f01, f04 and g02. p05 and p06 also differ in context limit, request slots and image; f04 and g02 in request slots 0 of 8 5-8%
with against without speculation, same weights: q01 and stock, q01 and q03, e01 and e02, g01 and g02 0 of 8 4-7%

So: on the official weights and the stock image, greedy output came back byte for byte after a restart, even with a different draft head. With 4-bit weights it did not, in any pair. And a run with a drafter never reproduced the run without one, on any weights. Read side by side (two prompts of p10 and e03), the texts part into equivalent wording: "a threading.RLock (or Lock) guarding" against "a single threading.RLock guarding". A strict restart of one unchanged configuration on the stock image is not among the saved runs. Nothing here is called lossless.

Long context

Needle retrieval on recipes/multi-user.env started with a 400k-token limit and 4 request slots (bench/longctx.py --needle-only, an editor's note with a catalogue number hidden at 10-90% of a wikitext haystack, 15 cases per size, greedy, thinking off; results/k01-longctx-100k-250k):

haystack found read rate (prompt tokens / request time, cold)
about 20k tokens (quality battery) 15/15 not timed
about 94k tokens 15/15 9,973 tok/s, about 9 s per request
about 231k tokens 15/15 9,367 tok/s, about 25 s per request

So the 4-bit attention indexer still selects the right blocks at 231k tokens. With that limit the server reports a KV pool of 2.5M tokens. Nothing longer than 231k was tried, and the official weights were not run at these lengths (their KV pool on this card holds 64k tokens), so this shows the 4-bit model works there, not how it compares.

recipes/single-user.env with a 140,000-token limit and three prompts of 112k-116k tokens, 1,024 output tokens each (results/l01-single-user-128k): the first pass waits 10.1 s for the first token and then decodes at 371.5 tok/s (greedy); the two passes after it, which repeat the prompts, start after 0.12 s and decode at 364.2 (greedy) and 359.8 (default sampling). With the short benchmark prompts the recipe reads 312-314 / 336-362; the prompts differ, so this shows no slowdown with a long prompt, not a gain. The folder holds the benchmark output only, no env.txt and no server.log.

Tool calling

bench/toolcall.py plays 88 scripted scenarios against the server with 32 tools in the request (file system, shell, SQL, tickets, calendar, e-mail, web and vector search; about 8,200 prompt tokens before the user speaks): single calls, argument extraction, cases where no tool should be called, chains, parallel calls, recovery from tool errors, long tool results and strict schemas. Tools answer from a fixed script, a check per scenario decides pass or fail. Each scenario was run three times per recipe, greedy, thinking on, four at a time (results/t01-toolcall):

recipe passed invalid JSON invented tools calls outside the schema
stock.env (official FP8 weights, MTP-3) 243 / 264 (92.0%) 0 0 0
multi-user.env (4-bit, calibrated head, MTP) 249 / 264 (94.3%) 0 0 0
single-user.env (4-bit, DFlash2 drafter) 245 / 264 (92.8%) 0 0 1

The three rows are not distinguishable: between the stock and the multi-user run one scenario flips (to the 4-bit side), eight differ only in how often they pass out of three, and three fail everywhere (single/read-file, extract/sql-params, schema/sql-mixed), which points at the check or the scenario before it points at the model. So the battery found no loss of tool-calling ability from the 4-bit recipes; it cannot show that there is none. The battery is new: before these runs it had only met a scripted endpoint (bench/test_toolcall.py), its final-answer checks are keyword based, and 88 scenarios make one flip worth 1.1 points. To compare two servers yourself:

python3 bench/toolcall.py a --url http://127.0.0.1:18040 --repeat 3 -c 4 --out results/x   # then the same as "b"
python3 bench/toolcall.py compare results/x/toolcall_a.json results/x/toolcall_b.json

Where a step goes

One decode step without speculation, 4-bit model with the calibrated int4 head, fused kernels off, profiled on the running server (bench/profile_step.py, output). The output file does not record these settings; they are in the command that produced it, line 11 of scripts/queue_h.sh. With the profiler attached the step takes 5.54 ms (5.36 ms without it). The GPU is busy for 97.3% of the step and idle for 0.15 ms, so the server's Python is not the cost: removing it entirely would gain at most 2.7%.

kernels launches per step summed time per step
marlin::Marlin (4-bit dense layers) 81 1.53 ms
cuBLAS gemvx (small 16-bit matrix-vector products) 191 1.08 ms
marlin_moe_wna16::Marlin (4-bit experts) 80 0.96 ms
two cutlass 16-bit GEMMs 162 1.16 ms
cuBLAS splitKreduce (second half of GEMMs counted above) 121 0.58 ms
everything else 711 1.29 ms
total 1,346 6.59 ms

The times add up to 6.59 ms, 119% of the step, because kernels run on two streams that overlap; the column shows where GPU time goes, not a split of the 5.54 ms. The profile names kernels, not modules: reading the gemvx and cutlass rows as the hyper-connections, routers and shared experts is an inference from the call counts.

About 350 small 16-bit matrix products of 5-8 microseconds each remain. They are too small to gain from 4-bit weights, so the lever is fewer launches. patches/hc-fused-sm89.patch fuses the hyper-connection kernels (VLLM_QWEN4_HC_FUSED_SM89=1, off by default):

unfused fused runs
cold bench, ms per pass of 81 modules, 1 / 4 / 8 / 16 positions 1.40 / 1.35 / 1.35 / 1.37 1.01 / 1.01 / 1.06 / 1.45 h01
server, no speculation, default / greedy 181.4-182.5 / 184.5-186.0 195.3 / 198.3 g01, i01
server, MTP-2, default / greedy 253.4-265.5 / 277.0-281.1 275.5 / 292.6 f04 and g02, i02

That is +7% without speculation and +4% to +9% with MTP-2, from one screening pass with the kernels on. g01 and g02 ran with 64 request slots, the fused runs with the default. At 16 positions the fully fused pair is slower than the unfused path in the cold bench, so the fused down kernel is limited to small batches (VLLM_QWEN4_HC_FUSED_SM89_DOWN_MAX_M, default 4; single-user.env sets 8).

24 GB cards

Measured to peak at 23.2 GiB on a 48 GB card; not yet run on a 24 GB card. Two recipes are meant for 24 GB. Both were started and used through the built image on the RTX 6000 Ada, with nvidia-smi sampled every 250 ms from before the start. All figures in this section are above the 3,142 MiB that other processes held on the card.

recipe serves KV pool peak while loading peak while serving record
fast-24gb.env text and images, 16k context, 2 slots 0.6 GiB, 18,484 tokens: one 16k request 22.71 GiB 23.21 GiB n01
fast-24gb-text.env text only, 32k context, 4 slots 1.1 GiB, 56,472 tokens: one 32k request or several shorter ones 22.68 GiB 23.24 GiB n02

A 24 GB card reports 24,564 MiB, 23.99 GiB, so these peaks leave 0.75-0.8 GiB. The KV pool is given in bytes and vLLM then ignores the memory-utilization setting (the server.log of m05 says so), so the recipes reserve the same KV pool on any card. To check yours, after docker build -t qwen4-fast:dev . and prepare/calibrate_head.sh:

bench/fit_check.sh recipes/fast-24gb.env        # or recipes/fast-24gb-text.env; about 3 minutes on our card

bench/fit_check.sh starts the recipe, samples memory from before the start, sends a 448x448 image and two 2048x1536 images (skipped when the recipe turns images off), two concurrent 512-token answers and a prompt that fills about 85% of the context, and writes field-reports/fit-<gpu>-<recipe>-<date>/fit.md. Please paste that file into an issue, a failed start included. On a machine with several NVIDIA GPUs it watches GPU 0 and pins the server to it (GPU_ID=1 for another); that path was not exercised, our machine has one GPU. n01 and n02 each hold 628 samples, about 157 s at the nominal 250 ms. Both name commit eea1275: that is the commit the working tree was based on, and the recipes, the four patches and fit_check.sh itself were not yet committed, so that commit alone does not reproduce them. The script now marks such a tree with -dirty. Not known:

  • Whether it fits a real 24 GB card. What the driver holds back there was not measured, and a desktop session or a browser on the same GPU can use up the 0.75-0.8 GiB that is left.
  • The text recipe beyond one screening run. 274.2 / 290.3 tok/s with its flags at 16k context and a 47,051-token pool (m01); no full run and no quality battery. The vision recipe has one full run through the built image (n03): 269.9-274.3 / 289.5-291.3 tok/s at one stream, 411 tok/s end to end at two, perplexity 7.413, GSM8K 97.5% of 200 (the 48 GB recipes: 98.5%; the difference is two questions). Its long-context step failed on a script fault since fixed (the default haystack did not fit 16k); n01 has the long prompt.
  • A larger pool. The text recipe with a 1.4 GiB pool (71,810 tokens) peaked at 23.53 GiB and was cut back (fit.md). single-user.env was not tried.

How the recipes were arrived at: five runs with scripts/memtrace_run.sh, all at 16k context with the calibrated int4 head, the fused kernels, VLLM_LOW_MEMORY_LOAD=1 and the embedding in host memory. Each trace is a column of MiB readings that starts at the baseline.

run differs in KV pool, tokens after the weights peak where the peak is
m01 text only, 4 slots, vLLM's budget set to 23.01 GiB by --gpu-memory-utilization 0.485 47,051 21.00 GiB 23.16 GiB during the benchmark (trace)
m02 vision on, 4 slots, 1 GiB pool, drafter experts 4-bit 30,667 21.71 GiB 24.10 GiB a spike of about 5 s right after the weights; 23.15 GiB during the benchmark (trace)
m03 vision on, 4 slots, 0.75 GiB pool 23,105 22.02 GiB 24.56 GiB the same spike; 23.24 GiB during the benchmark (trace)
m04 m03 plus --skip-mm-profiling 23,105 21.87 GiB 23.75 GiB no spike; 23.55 GiB in warm-up, 23.24 GiB in the benchmark, 23.75 GiB in the last 12 samples (trace)
m05 the settings of fast-24gb.env 18,484 21.54 GiB 23.19 GiB 22.71 GiB up to the end of the benchmark, 23.19 GiB in the last 136 samples (trace)

The traces have no timestamps; the phases are placed by the shape of the curve and the times in server.log. The benchmark levels of m02 to m04 are also the readings in their gpu_after.txt. Each env.txt records both the built image and a mounted patched tree. m04 and m05 were sent more requests after the benchmark. Of those the repository holds the needle test of m05: 15 of 15 found in haystacks of 12.6k-14.3k tokens (longctx_m05.json). That the others were 448x448 and 2048x1536 images and two concurrent streams, and that the 23.75 GiB of m04 came with a 2048x1536 image, is from the notes of the day; n01 repeats those requests on record.

What brings the peak down to 23.2 GiB:

  • VLLM_LOW_MEMORY_LOAD=1 (low-memory-load, lm-head-host-staging, mtp-borrows-target-tables). Without it the load of j01 peaked at 24.85 GiB; in m01 no reading during the weight load is above 21.6 GiB (the next item included). The patch headers read three causes off the j01 trace: memory that stays reserved after each layer is converted, 2.4 GiB while the output head is converted on the GPU, and 1.9 GiB of drafter tables that are built and thrown away. The three were not measured apart, and neither was the cost in load time.
  • --cpu-offload-gb 1 --cpu-offload-params embed_tokens (embed-tokens-host): the input embedding, 0.95 GiB, stays in pinned host memory. "Model loading took" falls from 20.76 GiB (j01) to 19.81 GiB (m01); the screening rates are 274.2 / 290.3 against 274.7 / 297.8 tok/s.
  • --skip-mm-profiling: m04 differs from m03 only in this flag and has no spike, so the spike is vLLM's start-up pass with a dummy image.
  • 4-bit experts in the MTP drafter (quantization_config in the speculative config, dflash2-cost-knobs): "Model loading took" 20.33 GiB (m02, m05) against 20.66 GiB (m03, m04).
  • A fixed, small KV pool and 2 slots (--kv-cache-memory-bytes): 0.6 GiB where m04 had 0.75 GiB and 4 slots. The text recipe drops the vision tower instead (19.81 against 20.66 GiB with the same drafter) and spends that on a 1.1 GiB pool.

Earlier attempts, before these patches, emulated the card with --gpu-memory-utilization 0.485 (23.01 GiB for vLLM's planning; it does not limit what the process takes). fast-4bit.env with vision on had no room for a KV cache at 32k context (p07), at 16k (p08) or at 8k with 23.7 GiB (p09). With the int4 head, 16k context, 4 slots and text only the server started with a KV pool of 21,005 tokens (p11, 256.6 / 277.2 tok/s) and, through the built image with the calibrated head and fused kernels, 21,425 tokens (j01, 274.7 / 297.8 tok/s). But the trace of j01 reaches 28,593 MiB at sample 169, 24.85 GiB above the baseline and more than a 24 GB card has; after that it stays at or below 23.5 GiB. That load peak is what the patches remove. The table of these runs is in docs/what-did-not-work.md.

What did not work

docs/what-did-not-work.md lists what failed to start, what ran and lost, and which measurements misled, each with its evidence.

Field tests

Only one card has been measured. docs/field-tests.md is a protocol of about 15 minutes per recipe (bench/field_report.sh) that writes a report to paste into an issue. The first report is this card running fast-4bit.env on the stock image. For the question "does it fit my card", bench/fit_check.sh took about 3 minutes on our card and reports the memory peak (24 GB cards); a report from a real 24 GB card is what is missing most.

Patches

patches/series lists eleven patches against vLLM 0.1.dev26393+gf247de72b, applied in order by the Dockerfile with patch --fuzz 0. Each patch is inactive unless the setting named below is given. That a patched server is numerically identical to the stock one was not shown: with the same flags, greedy output of the patched tree matched the stock image on 2 of 8 prompts (q05 and r01), where two stock-image starts matched on 8 of 8.

patch what it does measured effect default
qwen4-lm-head-quant passes the quantization config to Qwen4's lm_head, so a recipe can target it none alone; needed for the int4 head only when a recipe targets lm_head
lm-head-int4-sm89 fixes an assertion in Marlin when the load-time int4 head is used with the patch above: 228.8-240.9 to 255.1-262.0 tok/s, perplexity 7.345 to 7.463 (rows 8 and 10) same
mtp-draft-vocab the MTP drafter scores a counted subset of the output rows (VLLM_MTP_DRAFT_VOCAB_IDS) 210.3 against 206.8-208.2 tok/s with a borrowed id list (p04): inside the spread off; in no recipe
qwen4-dflash2-taps the Qwen4 model hands DFlash drafters the hidden states they need makes DFlash2 run: rows 9, 11, 15, 19 only with a dflash speculative config
lm-head-capture-and-load collects the head's input statistics (VLLM_LM_HEAD_CAPTURE_DIR); loads a precomputed int4 head (VLLM_LM_HEAD_INT4_FILE) perplexity 7.463 to 7.403 at the same speed (rows 10 and 14) off
dflash2-cost-knobs quantization_config inside the speculative config, to quantize chosen layers of a drafter not measured alone; see rows 11 and 15 off
hc-fused-sm89 fused hyper-connection kernels on sm_89 (VLLM_QWEN4_HC_FUSED_SM89=1) +7% without speculation, +4-9% with MTP-2 (above) off
low-memory-load releases the allocator cache after each layer converted at load (VLLM_LOW_MEMORY_LOAD=1) with the two below and the embedding patch: peak including load 23.16 GiB (m01) where the load of j01 reached 24.85 GiB (24 GB cards); not measured apart off
lm-head-host-staging the int4 head is quantized from host memory instead of from a 0.95 GiB copy on the GPU same off; same variable
mtp-borrows-target-tables the MTP drafter no longer builds its own embedding and head (2 x 0.95 GiB) before taking the main model's same off; same variable
embed-tokens-host --cpu-offload-gb 1 --cpu-offload-params embed_tokens keeps the input embedding in pinned host memory "Model loading took" 20.76 to 19.81 GiB (j01, m01); 274.2 / 290.3 against 274.7 / 297.8 tok/s, screening off

The "How checked" notes in the patch headers describe the CPU-only checks made when each patch was written; some still say the patch has not run on a GPU, and the four low-memory patches add a note on the GPU runs made since. The GPU results are the runs listed here. The MTP schedule in multi-user.env (num_speculative_tokens_per_batch_size) is a stock vLLM option, not a patch.

Licence and credits

Apache-2.0, see LICENSE and NOTICE.

  • HyperQwen (syv-ai, Apache-2.0): the approach as a whole. bench/prompts_real.jsonl is copied from it unchanged; bench/quality.py is adapted from its bench/quality_battery.py; the cohort protocol follows its bench/run_benchmarks.sh; the draft vocabulary (patches/mtp-draft-vocab.patch, prepare/build_draft_vocab.py) follows its patch and script of the same purpose; prepare/gptq_lm_head.py follows its drafter/gptq_utils.py and drafter/gptq_lm_head.py.
  • tonyd2wild/Qwen4-35B-A3B-RTX3090: patches/qwen4-dflash2-taps.patch follows its patches/qwen4_dflash2_taps.diff, which its header offers under the Apache License 2.0.
  • vLLM (Apache-2.0): every file the patches change.
  • RadixArk/Qwen4-35B-A3B-Dflash2: the drafter checkpoint. It is not redistributed here; you download it from Hugging Face under its own terms.
  • wikitext-2 and GSM8K: fetched to your machine by bench/fetch_quality_data.py, not redistributed.

関連プロジェクトを探す

読み込み中…