Qwen3.5-4B-3D-Coder, tuned for decode speedQ5_K_M on 12 GB
A 4B three.js scene writer that fits in VRAM at any quant. Q5_K_M without speculation ships at 77.5 tok/s task-weighted, 1.28x the Q8_0 baseline; the restored MTP head reaches 101.7 and stays opt-in.
- Decode · task-weighted (55% reasoning, 45% writing code)
- 77.5tok/sstock 60.6
- Prefill · 32k prompt, 12.9 s
- 2,480tok/s
- Context
- 64k tokens
- VRAM peak
- 7.1GB
TUNED STOCK FLAGS
Run it
tools/download.sh && tools/build_quants.sh && ./serve.sh
| Model | ccore/Qwen3.5-4B-3D-Coder on Hugging Face |
|---|---|
| Weights | GGUF Q5_K_M from ccore/Qwen3.5-4B-3D-Coder at 4b9f05fOur own quant, built by tools/build_quants.sh from the checkpoint with the base model's 15 mtp.* tensors (Qwen/Qwen3.5-4B) grafted back in. |
| Engine | llama.cpp b12242 (3b4d6ab3f) · CUDA 12.8 |
| Placement | Everything in VRAM (7.1 GB of the card while serving at 64k). |
| Hardware | NVIDIA GeForce RTX 3060 12 GB · 62 GB RAM · Intel Core i5-12500 · NVMe SSD VRAM bandwidth measured at 342 GB/s (cuBLAS SGEMV, 1 GiB). |
| API | OpenAI-compatible on port 8083 |
| Key flags | -ngl 99 -fa on -ctk f16 -ctv f16 -c 65536 -np 1 -ub 2048 no speculation by default; QC_SPEC=draft-mtp to opt in sampling from the model card: T 0.6, top-p 0.95, top-k 20 |
- MTP is opt-in. No engine bug was found and the page pass rate is the same (10/16 vs 9/16), but 5 of 19 finished MTP pages failed on syntax errors against 0 of 35 without speculation; the cause is unknown and may be chance.
- Q4_K_M is faster but 62% of its finished pages throw an error.
- DFlash is the fastest while writing code (163 tok/s) and loses while reasoning (acceptance 4-7%), so it is not used.
- The decode baseline is the official Q8_0 without speculation.
Measured results
| Metric | Conditions | Measured | Stock | Ceiling | Source line |
|---|---|---|---|---|---|
| Decode | task-weighted (55% reasoning, 45% writing code) | 77.5 tok/s | 60.6 | RESULTS.md:34 | |
| while reasoning | 80.7 tok/s | 62.5 | RESULTS.md:34 | ||
| while writing the page | 74 tok/s | 58.3 | RESULTS.md:34 | ||
| opt-in: restored MTP head, n=2, task-weighted | 101.7 tok/s | 60.6 | RESULTS.md:36 | ||
| Q4_K_M without speculation (rejected: fails the render eval) | 84.8 tok/s | 60.6 | RESULTS.md:33 | ||
| Prefill | 32k prompt, 12.9 s | 2,480 tok/s | RESULTS.md:43 | ||
| 62k prompt, 29.9 s | 2,070 tok/s | RESULTS.md:43 | |||
| VRAM peak | whole card while serving, no speculation (8.0 with MTP) | 7.1 GB | RESULTS.md:150 | ||
| Quality | mean KL divergence, Q5_K_M | 0.00732 KLD | RESULTS.md:85 | ||
| render eval: pages that work out of 20 (Q8_0: 10, Q4_K_M: 5) | 9 pages | RESULTS.md:51 |
Reproductions
None yet. If you ran this on your own 3060, report your numbers and they appear here with your hardware.
Findings from this recipe
The desktop session holds about 0.95 GB of the card and that decides several fits
A 12 GB card that also drives the desktop is an 11 GB card.
A port-based health check can be answered by someone else's server
A harness that waits for `/health` on a port and then runs its tests will measure whatever answers on that port.
A one-sample-per-prompt check wrongly blamed an engine bug for MTP failures
The first quality check of the restored MTP head used one answer per prompt and looked decisive: 1 of 8 pages worked with MTP against 6 of 8 without, and 5 of 9 answers looped against 0 of 8.
On a small all-VRAM model decode is already at 74-93% of the bandwidth ceiling
Before writing a custom kernel for a model that fits in VRAM, compare measured time per token with bytes read per token divided by measured bandwidth.
A drafter trained on the base model loses on a fine-tune that reasons tersely
The z-lab DFlash drafter for Qwen3.5-4B is a clear win on the base model and a loss on the 3D-Coder fine-tune.
Greedy-output identity is the wrong quality gate when placement changes
Comparing greedy output hashes before and after a change flags valid configurations as broken whenever the change moves computation between CPU and GPU.
Q4_K_M is the fastest 3D-coder quant and breaks twice as many pages
On a 4B model that writes about 10k tokens of JavaScript per answer, Q4_K_M's speed is not usable.
A fine-tune that dropped its MTP head can take the base model's head back
Qwen3.5-4B-3D-Coder's config declares one MTP layer, but the released weights and official GGUFs carry none.
q8_0 KV costs 29% decode at 32k on a model with few full-attention layers
Quantized KV cache is slow on llama.cpp for models with few full-attention layers.
Thanks
- ccore The fine-tune we serve; the render eval's prompts come from the dataset's validation split.
- Qwen The 15 mtp.* tensors grafted back into the 3D coder came from Qwen3.5-4B; Kintsugi-27B is built on Qwen3.8-27B.
- z-lab Measured against MTP on the 3D coder: fastest while writing code (163 tok/s), not used because acceptance falls to 4-7% while reasoning.
- llama.cpp (ggml-org and contributors) The engine for Flint, the 3D coder and Inkling-2-Mini, and the base of the Kintsugi fork.
- ggml-org Flint-Q4_K_M.gguf and Inkling-2-Mini-IQ4_NL.gguf are the files the two recipes serve; the Q8_0 files are the KLD references.
- Hugging Face Every model, quant and drafter in these recipes is fetched from the Hub at a pinned revision and checked against the API's sha256; the base model's MTP tensors were fetched with HTTP range requests.
- NVIDIA Every recipe runs on CUDA on this card; cuBLAS SGEMV is our VRAM bandwidth probe (342 GB/s), nvidia-smi dmon is the telemetry, and Inkling's experts ship in NVFP4.
Full write-up
Serving ccore/Qwen3.5-4B-3D-Coder as fast as possible on the RTX 3060 12 GB. The model is a Qwen3.5-4B fine-tune that reasons, then writes a complete three.js page.
It fits in VRAM at any quant. So this recipe is about decode speed on a model that already fits:
- choosing a quant;
- bringing back the base model's multi-token-prediction (MTP) head, which the release dropped;
- tuning speculation for a task that switches from prose (reasoning) to code.
Numbers, the quality eval and the CUDA-kernel analysis are in RESULTS.md. The experiment log is PLAN.md. Raw data is in runs/.
Result
| Single user, 64k context | Q8_0 official, no speculation | This recipe: Q5_K_M |
|---|---|---|
| Decode while reasoning | 62.5 tok/s | 80.7 tok/s |
| Decode while writing the page | 58.3 tok/s | 74.0 tok/s |
| Task-weighted decode | 60.6 tok/s | 77.5 tok/s (1.28×) |
| Prefill, 32k prompt | 12.9 s (2,480 tok/s) | |
| KL divergence vs F16 | 0.001 | 0.007 |
| Render eval, pages that work (20 prompts) | 10 | 9 |
The restored MTP head takes Q5_K_M to 101.7 tok/s (1.68×) on the speed sessions, and 105.7 vs 75.0 tok/s median on real 8-prompt answers. It is opt-in, not the default. Its first check, one answer per prompt, failed (1 page of 8 worked against 6) and looked like an engine bug in rolling back DeltaNet state. The follow-up did not bear that out. MTP's state matches a clean prefill through 12k tokens. It loops no more often (0/16 vs 2/16 on the prompts that looped). With 2 seeds on the same 8 prompts, 10/16 pages worked against 9/16. What keeps it off by default: 5 of its 19 finished pages failed on syntax errors (mostly a name declared twice), against 0 of 35 for Q5_K_M without speculation. A re-score of every token on a no-spec server found nothing MTP picked that plain decoding couldn't (2 of 116k tokens vs 2 of 103k), so the excess has no known cause and may be chance; a default change waits for a render comparison sized to settle it (RESULTS.md, "Does MTP break long answers?"). To use it: QC_SPEC=draft-mtp ./serve.sh.
Q4_K_M is faster again (84.8 tok/s without speculation), but 62% of its finished pages threw errors (THREE.Object33D, duplicate declarations), and it passed 5 of 20 prompts.
Use it
tools/download.sh # pinned GGUFs, base-model MTP tensors, DFlash drafter, eval data (sha256-checked) tools/build_quants.sh # CPU only: graft the MTP head, convert to F16, quantize Q8_0/Q6_K/Q5_K_M/Q4_K_M ./serve.sh # llama-server on 127.0.0.1:8083 through gpu_run, OpenAI-compatible
The defaults in serve.sh are:
- our Q5_K_M (the file carries the MTP head, unused unless
QC_SPEC=draft-mtp); - no speculation;
-fa on, f16 KV, 64k context, one slot;-ub 2048;- the model card's sampling (T 0.6, top-p 0.95, top-k 20).
Overrides: QC_MODEL (e.g. our Q4_K_M for 5% more speed and more broken pages), QC_SPEC=draft-mtp, QC_DRAFT_MAX, QC_CONTEXT, QC_PORT.
Why the MTP head had to be restored
The config declares mtp_num_hidden_layers: 1, but the released safetensors (723 tensors) and the official GGUFs (nextn_predict_layers = 0) have no MTP weights.
tools/fetch_mtp.py fetches the 15 mtp.* tensors of base Qwen/Qwen3.5-4B with HTTP range requests (241 MB). tools/make_src.py then adds them to the fine-tune's checkpoint. llama.cpp's converter turns that into blk.32.nextn.*.
The base head was never trained on the fine-tune's hidden states. Even so, it is accepted 86% of the time while the model writes code. While it reasons, the rate drops to 37%. The speed-up is real; the output-quality problem above has to be fixed in the engine before it can ship.
Tools
| Script | What it does |
|---|---|
tools/ceiling.py |
per-category bytes per token and the decode ceiling of a GGUF |
tools/gpubw.py |
VRAM bandwidth probe (cudart memcpy + cuBLAS SGEMV), no nvcc needed |
tools/benchsession.sh |
a plan of llama-bench runs inside one gpu_run session, with telemetry |
tools/ab.py |
llama-server A/B sessions with interleaved controls, appended to runs/ledger.jsonl |
tools/ledger_summary.py |
per-config medians and the task-weighted rate |
tools/kld.sh |
KL divergence of every quant against our F16 on held-out answers |
tools/evalrun.sh, gen.py, render.mjs, score.py |
the render eval: generate, render in headless Chromium on the CPU (SwiftShader), score |
tools/qualify.sh |
acceptance gates for serve.sh: chat, scenes (--scene-only --ids), needles at 32k and 62k |
tools/eval_table.py, loop_check.py |
side-by-side render-eval table; flags answers that loop |
Credits
- llama.cpp b12242 for the engine, the converter, MTP and DFlash.
- The model's author ccore, for the fine-tune and the ThreeJS-3D-Scenes dataset. The eval prompts come from its validation split.
- Qwen, for the Qwen3.5-4B base model and its MTP head.
- z-lab, for the Qwen3.5-4B-DFlash drafter.
The race video
promo/ holds a side-by-side time-lapse: the same prompt (a voxel bonsai) sent to the Q8_0 baseline and the tuned Q5_K_M server, each scene growing mesh by mesh as its code streams in. Both sides run on one clock at the same speed-up, so the gap at the finish is the real gap.
promo/session.sh+promo/capture.pystream each answer with per-chunk timestamps intopromo/captures/<prompt>/.promo/tools/buildseq.mjsreplays each page in headless Chromium and saves a frame per batch of meshes;promo/tools/prep.pymaps every mesh to the moment its code arrived.promo/src/Race.tsxis the Remotion composition (render with the Flint promo'snode_modules).
The two quants write different code from the same seed, so the pages differ. The bonsai pair was picked because the token counts are close (14,097 stock, 15,213 tuned), so the finish gap understates the decode speedup rather than inflating it.
recipe.json · Markdown · Folder with scripts and raw runs · Full results log