GGUF quants of Qwen3.6-35B-A3B-TinyKV: Qwen3.6-35B-A3B with a 2.5× smaller KV cache, from retraining only its 10 full-attention layers by distillation.
These files need the
tinykvbranch of llama.cpp: riceharvest/llama.cpp@tinykv. Stock llama.cpp, Ollama and LM Studio refuse them (they don't know the shared, compressed cache layout).
git clone -b tinykv https://github.com/riceharvest/llama.cpp && cd llama.cpp
cmake -B build -DGGML_CUDA=ON # or -DGGML_VULKAN=ON / -DGGML_SYCL=ON / CPU: no flag
cmake --build build -j 8 --target llama-server llama-cli
./build/bin/llama-server -m Qwen3.6-35B-A3B-TinyKV-Q4_K_M.gguf -c 131072 -fa on -ngl 99
Use -fa on. Without flash attention llama.cpp pads the V cache to the widest layer and gives back part of the saving.
| Per token | f16 cache | q8_0 cache (-ctk q8_0 -ctv q8_0) |
q4_0 cache (-ctk q4_0 -ctv q4_0) |
|---|---|---|---|
| Qwen3.6-35B-A3B | 20,480 B | 10,880 B | 5,760 B |
| TinyKV | 8,192 B | 4,352 B | 2,304 B |
| 128k context | 1.07 GB (stock 2.68 GB) | 0.57 GB (stock 1.43 GB) | 0.30 GB (stock 0.75 GB) |
| 262k context | 2.15 GB (stock 5.37 GB) | 1.14 GB (stock 2.85 GB) | 0.60 GB (stock 1.51 GB) |
Quantized caches need -fa on. The model was trained with its cache rounded to NVFP4, a 4-bit format close to q4_0, and
the q4_0 cache holds up (measured, same setup as the checks below):
| q4_0 KV cache | vs PyTorch | 30k needles | 130k needles |
|---|---|---|---|
| TinyKV Q8_0 | 0.057 (f16 cache: 0.047) | 24/24 | 8/8 |
| TinyKV Q4_K_M | 0.088 (f16 cache: 0.082) | 24/24 | 7/8 |
| stock Q8_0, vs the original | 0.084 (f16 cache: 0.077) | 24/24 | 6/8 |
The Gated DeltaNet layers add a fixed ~60 MB of recurrent state per sequence, independent of context length.
Sanity check: a randomly picked quant (MXFP4_MOE) served by this branch's llama-server on an Intel Arc Pro B70
(Vulkan) answers coherently: a kid-level explanation, a correct Python function, correct arithmetic, fluent Dutch, a
correct tool call, and a correct reasoning answer with thinking on. Full outputs: results/sanity_mxfp4_b70_vulkan.txt.
Longest context that fits fully on one GPU, TinyKV / stock Qwen3.6-35B-A3B at the same weight size (only the
KV cache differs), with -fa on. Capped at 262k, the model's native context. Bold: TinyKV reaches the full 262k where
stock doesn't.
f16 cache (default):
| Quant | 16 GB | 24 GB | 32 GB | 48 GB |
|---|---|---|---|---|
| Q8_0 | — / — | — / — | — / — | 262k / 262k |
| Q6_K | — / — | — / — | 262k / 185k | 262k / 262k |
| Q5_K_M | — / — | — / — | 262k / 262k | 262k / 262k |
| Q4_K_M | — / — | 262k / 118k | 262k / 262k | 262k / 262k |
| MXFP4_MOE | — / — | 262k / 206k | 262k / 262k | 262k / 262k |
| IQ4_XS | — / — | 262k / 241k | 262k / 262k | 262k / 262k |
| Q3_K_M | — / — | 262k / 262k | 262k / 262k | 262k / 262k |
| IQ2_M | 262k / 157k | 262k / 262k | 262k / 262k | 262k / 262k |
q8_0 cache (-ctk q8_0 -ctv q8_0):
| Quant | 16 GB | 24 GB | 32 GB | 48 GB |
|---|---|---|---|---|
| Q8_0 | — / — | — / — | — / — | 262k / 262k |
| Q6_K | — / — | — / — | 262k / 262k | 262k / 262k |
| Q5_K_M | — / — | — / — | 262k / 262k | 262k / 262k |
| Q4_K_M | — / — | 262k / 223k | 262k / 262k | 262k / 262k |
| MXFP4_MOE | — / — | 262k / 262k | 262k / 262k | 262k / 262k |
| IQ4_XS | — / — | 262k / 262k | 262k / 262k | 262k / 262k |
| Q3_K_M | — / — | 262k / 262k | 262k / 262k | 262k / 262k |
| IQ2_M | 262k / 262k | 262k / 262k | 262k / 262k | 262k / 262k |
How it's computed: weights on the GPU + KV cache + 628 MiB compute buffer + 63 MiB Gated DeltaNet state (all three
measured in llama.cpp on the box: at 130k context the KV cache was 1,018 MiB for TinyKV vs 2,545 MiB for stock) + an
estimated 0.8 GB for the CUDA context and driver reserve. A desktop that also drives a display has less: subtract what
your desktop uses. Partial offload to CPU (-ngl below 99, or --n-cpu-moe) runs the larger quants on smaller GPUs at
lower speed.
With --n-cpu-moe 99 (or -ot "exps=CPU") the MoE experts stay in system RAM and the GPU keeps only the rest of the
model (about 1.4-2.1 GB, measured per quant) plus the KV cache. Then the KV cache decides what fits, and TinyKV's is 2.5×
smaller:
| Full 262k context, f16 cache | GPU needs (TinyKV) | GPU needs (stock) | System RAM for the experts |
|---|---|---|---|
| Q8_0 | ~5.6 GB (fits 8 GB) | ~8.6 GB | ~35 GB |
| Q4_K_M | ~5.2 GB | ~8.1 GB | ~20 GB |
| IQ2_M | ~5.0 GB | ~8.0 GB | ~11 GB |
With room to spare, keep some expert layers on the GPU for speed (--n-cpu-moe N offloads only the first N layers'
experts). Q8_0 at the full 262k, expert layers that still fit on the GPU (of 40), TinyKV / stock:
| f16 cache | q8_0 cache | q4_0 cache | |
|---|---|---|---|
| 8 GB | 3 / doesn't fit | 4 / 2 | 4 / 3 |
| 12 GB | 7 / 4 | 9 / 7 | 9 / 8 |
| 16 GB | 12 / 9 | 14 / 12 | 14 / 13 |
With a quantized cache the cache is small for both, so the gap narrows; at f16 and q8_0 TinyKV's freed memory buys 2-3 extra expert layers on the GPU.
So an 8 GB card runs the biggest quant at the full context with TinyKV, where stock fits only at about 2 bits (and with q8_0 cache). Same estimate as above: non-expert weights + KV + measured buffers + ~0.8 GB assumed overhead. Decode speed then depends on system RAM bandwidth, since ~3B active parameters per token are read from RAM.
What to move off the GPU first, cheapest first:
--no-mmproj-offload keeps it on the CPU (~0.9 GB of VRAM back); text-only use doesn't load one.--cpu-moe puts every expert in system RAM; --n-cpu-moe N only the first N layers' experts,
so you can fill the GPU with the rest. Attention, the KV cache and the shared expert stay on the GPU either way, which is
what keeps long context fast. With TinyKV the cache leaves 2-3 more expert layers on the GPU (table above).-ot "blk\.(3[0-9])\.ffn_.*_exps=CPU" moves the experts of layers 30-39 only; any regex on tensor names
works, e.g. to keep the last layers' experts on the GPU instead of the first.--fit on -c 262144 sizes the offload to your free VRAM; --fit-target sets the margin to keep.-ctk q8_0 -ctv q8_0 (or q4_0) with -fa on. Keep the cache on the GPU: --no-kv-offload moves it to
system RAM and makes long prompts slow, and with TinyKV it is small enough not to need that.-ub 256 (default 512) shrinks the GPU compute buffer a little at some prefill speed.-np 4 -c 262144 splits one cache between 4 slots; --kv-unified-per-slot caps each slot.--mlock keeps them
resident, -t = your physical core count.Every quant uses an importance matrix computed with the TinyKV model itself (160 × 2k tokens of the training mix), keeps
the 10 full-attention layers' q/k/v/o at Q8_0, and keeps the cache maps (attn_tk_*) in F32.
| File | Size | GPU (weights + ~128k ctx) | vs PyTorch | 30k needles | 130k needles |
|---|---|---|---|---|---|
Qwen3.6-35B-A3B-TinyKV-Q8_0.gguf |
37.8 GB | 48 GB+ | 0.047 | 24/24 | 8/8 |
Qwen3.6-35B-A3B-TinyKV-Q6_K.gguf |
29.4 GB | 32 GB (short ctx) / 48 GB | 0.049 | 24/24 | — |
Qwen3.6-35B-A3B-TinyKV-Q5_K_M.gguf |
25.6 GB | 32 GB | 0.070 | 24/24 | — |
Qwen3.6-35B-A3B-TinyKV-Q4_K_M.gguf |
22.1 GB | 24–32 GB | 0.082 | 24/24 | 8/8 |
Qwen3.6-35B-A3B-TinyKV-MXFP4_MOE.gguf |
20.3 GB | 24–32 GB | 0.161 | 24/24 | — |
Qwen3.6-35B-A3B-TinyKV-IQ4_XS.gguf |
19.5 GB | 24 GB | 0.097 | 23/24 | — |
Qwen3.6-35B-A3B-TinyKV-Q3_K_M.gguf |
17.6 GB | 24 GB | 0.154 | 24/24 | — |
Qwen3.6-35B-A3B-TinyKV-IQ2_M.gguf |
12.6 GB | 16 GB | 0.254 | 23/24 | 6/8 |
IQ2_M keeps the MTP layer (unused by llama.cpp here) at Q4_K: 2-bit quants need importance data, and that layer never runs during the imatrix pass. It is the lossy end of the ladder.
Reference, same needles and setup: stock Qwen3.6-35B-A3B Q8_0 (unsloth) finds 24/24 at 30k and 5/8 at 130k, and differs from the original bf16 model by 0.077 on the same prompts.
Checks (run on an RTX PRO 6000 with this branch, CUDA, -fa on):
See the main model card for how it works, the training recipe, the quality tables (held-out needles at 30k/130k, KL per source) and the vLLM plugin. In short: layers 19, 27 and 39 read the cache of layers 15, 23 and 35; the other owners store keys as 64 exact RoPE dims + 64 compressed dims and values as 128 compressed dims (layer 35 stays full width); small linear maps around stock attention do the rest.
Text only: the vision tower is unchanged, but image input was not tested with the new attention (use the stock Qwen3.6-35B-A3B mmproj at your own risk).
Made by @imdariotoo. I post my local-model releases on X, so follow there for the next ones.
Training, evaluation and these quants' checks ran on CloudRift RTX PRO 6000 GPUs, provided through their AI Builder Grant. Thanks to CloudRift for the compute.
Apache-2.0, as the base model (Qwen/Qwen3.6-35B-A3B).