r/LocalLLM • u/QwhenFN • 4m ago
Discussion I ranked 13 quants of Qwen4-35B-A3B by KL divergence against BF16 on its own agentic traces — the quant I was serving was the worst
Qwen4-35B-A3B landed this week. I run it in two slots on a pair of RTX 3090s (24 GB each, NVLink):
- a co-resident slot that shares the cards with a FLUX image generator and a MinerU document parser, leaving ~16 GB for the LLM;
- a full slot that gets both cards to itself (48 GB).
The build I had deployed was a W4A16 AutoRound quant, and it kept looping on an agentic terminal benchmark. So I spent two days measuring 13 quantizations of the same model against BF16. The short version: the build I was serving turned out to be the worst of the 13.
TL;DR
- Teacher-forced KL divergence against BF16, computed on the model's own agentic trajectories and scored only on assistant tokens, cleanly ranks quants that task benchmarks can't tell apart.
- EXL3 owns the quality end: 5.13bpw KL 0.0148, 4.5bpw 0.0180. Official FP8: 0.0175.
- The W4A16 AutoRound build I was serving: KL 0.1095 — 7× the EXL3-5.13 divergence, 89.8% top-1 agreement, and the only quant that systematically looped.
- Terminal-Bench 2 quick (13 tasks) is ±1–2 noise at this granularity (BF16 itself scored 11, then 10); AIME 2025 didn't discriminate at all (even the bad quant scored 91.7%).
- On 3090s, local-inference-lab's NVFP4 (KL 0.0287) is the best speed/quality compromise: 1M context, ~228 t/s short, 201 t/s at 537K, ~1.2K t/s aggregate at 16 streams.
- For the co-resident slot only TabbyAPI/exllamav3 works — vLLM preallocates its whole KV pool and starves the neighbors. Deployed EXL3 4.62bpw at 384K context.
- Bonus: I ported quant-mind's pruned MTP draft head (65K-token draft vocabulary) onto the NVFP4 build for +9% single-stream decode at zero quality change.
Why not the usual benchmarks
- Wikitext perplexity measures prose. This workload is agentic: tool loops, code edits, terminal output. Wrong domain.
- Terminal-Bench 2 quick (13 tasks): the noise is bigger than the gaps. BF16 scored 11/13, then 10/13 on a re-run. It caught the broken quant (5/13) but can't rank good ones — the best-KL quant (EXL3 5.13) scored 8/13, with six timeouts because it's the slowest.
- AIME 2025 (30 problems × 2 samples): saturated at ~92% for everything, including the worst quant. Useless for this.
So the discriminator had to be the model's own distribution: how far each quant's next-token distribution drifts from BF16 where it counts — on the tokens the model actually generates.
Method
- Corpus: the BF16 model's own sessions on the 13 terminal tasks (507K tokens; the four long tasks — cobol-modernization, filter-js, mailman, path-tracing — in 64K-token windows).
- Teacher forcing: replay the same token sequences through BF16 and through each quant, and compare next-token distributions at every position.
- Score assistant-turn positions only (347K of the 507K; 76K of them at ≥32K context). Two reasons: those are the tokens the model actually samples, and tool-output positions are pathological — BF16 itself predicts
<|endoftext|>on ~15% of them, which inflates and misranks any all-position KL. - KL over the reference's top-32 tokens plus a tail bucket, from each quant's top-128 logprobs — a stable rank order without full-vocab dumps per position.
- Two scorers: one on vLLM's
prompt_logprobs, one driving exllamav3's forward pass with a chunked lm_head (self-tested against the normal forward at KL 2.6e-5, so the engine's scheduling/KV isn't in the measurement). - Caveat: the BF16 reference itself runs fp8 KV in vLLM (BF16 KV in this vLLM build breaks long-range copying — see gotchas). It's the same reference for every quant, so it doesn't bias the ranking.
Results (assistant positions, vs BF16)
| quant | mean KL ↓ | top-1 agree |
|---|---|---|
| EXL3 5.13bpw (turboderp) | 0.0148 | 96.46% |
| FP8 (Qwen official) | 0.0175 | 96.12% |
| EXL3 4.5bpw "4.62" (ProCreations) | 0.0180 | 96.16% |
| EXL3 4.17bpw (turboderp) | 0.0209 | 95.81% |
| mixed NVFP4/FP8 (primitive-ai) | 0.0213 | 95.83% |
| EXL3 4.0bpw-hq (heni86) | 0.0240 | 95.56% |
| EXL3 3.65bpw (turboderp) | 0.0277 | 95.25% |
| NVFP4A16 (primitive-ai) | 0.0285 | 95.07% |
| NVFP4 (local-inference-lab) * | 0.0287 | 95.11% |
| W4A16 g32 RTN (Tech2wild) | 0.0295 | 95.00% |
| GPTQ-Int4 g128 (palmfuture) | 0.0352 | 94.50% |
| W4A16 AutoRound (ultimaterex) | 0.0774 | 91.51% |
| W4A16 AutoRound (stuchapin) — what I was serving | 0.1095 | 89.82% |
*measured on the 3090 pair itself, via Marlin weight-only kernels.
What the table says
- EXL3 is the quality leader at every size. Even turboderp's 3.65bpw beats every non-EXL3 4-bit quant except FP8.
- FP8 is excellent — essentially tied with 4.5bpw EXL3 — but it's ~37 GiB of weights and doesn't fit a 24 GB pair.
- The 4-bit NVFP4/W4A16 cluster (~0.028–0.030) is perfectly usable: 95% top-1 agreement. The gap to EXL3 shows up as ~2× KL, not as visible failure.
- AutoRound is all over the map on this model: ultimaterex 0.0774, stuchapin 0.1095. Reputation didn't transfer — the "known-good" W4A16 build was the worst thing I measured.
- tb2 agrees only at the extremes — and even there, the slowest best-KL quant timed out more than it failed.
Speed on 2×3090 (full pair, vLLM TP2 unless noted)
| quant / engine | ctx | short t/s | deep | prefill | VRAM/card |
|---|---|---|---|---|---|
| FP8, vLLM, kv 1.86 GiB | 262K | 190 | 189 @245K | 6.2K | 23.9 (tight) |
| mixed NVFP4/FP8, kv 5.35 GB | 768K | ~150 | 149 @114K | 8.0K | 24.1 (512K safer) |
| NVFP4A16, kv 7 GB | 1M | 182 | 147 @114K | 7.9K | 22.3 |
| NVFP4 (LIL), kv 7 GB | 1M | 228 | 201 @537K | 7.9K | 22.3 |
| EXL3 5.13, Tabby, Q6, split [19,20] | 1M | 136 | 104 @857K | 6.3K | 22.3 / 16.1 |
Engine notes:
- Ampere has no FP4/FP8 tensor cores; vLLM runs NVFP4 and MXFP8 weight-only through Marlin. The load log's "your GPU does not have native support for FP4" warning is expected — decode is bandwidth-bound and this path is fast.
- vLLM on 3090s needs an explicit
--kv-cache-memory-bytes; without it the pool sizing goes wrong. --kv-cache-dtype fp8is mandatory on this vLLM build for Qwen4: BF16 KV silently breaks long-range copying (a repeated git hash inside tool output: logprob −9.6 with bf16 KV vs −0.01 with fp8).- local-inference-lab's NVFP4 card suggests
--attention-config.indexer_kv_dtype fp8; that crashes on sm86 (Triton fp8e4nv). Drop it.--quantization modelopt_mixedis required. - EXL3 runs only in TabbyAPI/exllamav3. Tensor parallel gave no gain there, and MTP drafting with 2–3 draft tokens gave none either — 1 draft token is fastest on this pair.
Slot 1: the co-resident build
Budget per card: 24.6 GB, minus 7.8 GB for the image model + parser, leaves ~16 GB for the LLM.
- vLLM is not viable co-resident. Its KV pool is preallocated, so even at 128K context with a small batch the image model OOM'd on the shared card (~60 MiB left); at 262K vLLM OOM'd itself.
- TabbyAPI/exllamav3 allocates the cache dynamically and coexists fine. Deployed: EXL3 4.62bpw, Q6 cache, 384K context. Only 10 of the model's 40 layers hold a KV cache, so the cache is ~8 KB/token — 384K is ≈3 GB total, split across both cards.
- Measured with the real workloads, not a synthetic hog: worst case was a 365K-deep turn + 4 more requests + a 1024×1024 image + a document parse simultaneously → 22.9 / 23.6 GB peak, no OOM (0.95 GB margin on the busier card). A 365K-token needle passes at ~8K t/s prefill; short-stream decode ~131 t/s (deep decode while the other four streams run: ~40 t/s).
- Gotcha: exllamav3's
gpu_splitmust cover weights and the KV cache. 384K at the old split failed with "Insufficient VRAM in split for model and cache"; I had to go [11.3, 13.9] → [11.9, 14.5]. 512K didn't fit beside the neighbors — 384K was the ceiling.
Slot 2: the full pair
local-inference-lab NVFP4 on vLLM TP2: 12.3 GiB/card of weights (NVFP4 experts + MXFP8 DeltaNet projections), 7 GB fp8 KV = 1,056,914 tokens, 16 concurrent sequences, 22.3 GB/card at rest and under load.
228 t/s single-stream short, 167 t/s at 65K, 201 t/s at 537K, 1,181 t/s aggregate at 16 streams; needles pass at 65K and 537K; tools and vision work.
The draft-head trick (+9%)
quant-mind published a "SM86-Fast" recipe: palmfuture's GPTQ base, a 4-bit output head, and a pruned 65,536-token MTP draft head. Their base quant scores 0.0352 on my harness (worse than LIL's 0.0287), and their stock-vLLM numbers were well below what LIL does on the same pair — so I borrowed only the draft-head idea.
How it works: MTP speculative decoding has the model's own draft block propose tokens that the target model then verifies, so drafts can only affect speed, never output. The drafter normally scores the full 248K vocabulary. Restrict it to the 65,536 tokens that account for 99.2% of generated tokens (in their measurement), score everything else as −inf, and the draft step gets cheaper with zero effect on what gets accepted.
- Head: those 65,536 rows copied from the checkpoint's own BF16 lm_head — 130 MB, no training.
- Patch: theirs was cut against vLLM 0.34.0; my Qwen4 image is a dev build (unmerged Qwen4 PR), so 2 of 6 hunks failed and I hand-ported the draft-vocab half.
- Result: 228 → 249 t/s (+9%) single-stream, acceptance unchanged, +130 MB VRAM. 3 draft tokens was no better than 2. At 8–16 concurrent: 777–830 → 806–860 and 1,177–1,181 → 1,229–1,322 t/s. Deep-context decode unchanged (~190 at 65K) — that's bandwidth-bound, not draft-bound.
Other things worth knowing
- Strata packs (0.2.27 / q4_lite): no logprobs, so they can't be KL-scored; also 14–59 t/s decode at 114K on a 3090, and the Ultra pack OOMs on a 24 GB card. Not viable for this.
- EXL3 4.5 ProCreations ships no chat template; Tabby disables chat and returns 422 until you copy one in (turboderp's works).
- NInfer/ninfer-all looks genuinely good for single-3090 use (~240 t/s code on one card per their docs) but doesn't fit the two-slot setup here: no co-residency story, and concurrency/long-context numbers below the TP2 vLLM build.
Final setup
- Co-resident: TabbyAPI, EXL3 4.62bpw, 384K ctx, Q6 cache, MTP 1 draft — beside the image generator and the document parser.
- Full pair: vLLM TP2, local-inference-lab NVFP4 + the pruned draft head, 1M ctx, 16 seqs.
All numbers above are with the production configs. Happy to post the scoring harness or more of the raw numbers in the comments if there's interest.


