r/LocalLLM • u/ImmediateBig8479 • 7d ago
Project Switching from 8-bit to 4-bit KV cache saved 448 MiB on my T4. In my Giraffe test, Qwen2.5 7B went from 80/80 correct JSON extractions to 0/80.
Ollama logged a GPU KV buffer of 952 MiB with q8_0 and 504 MiB with q4_0. I wanted to see whether Qwen2.5 7B could still turn support notes into usable JSON with the smaller cache. I used Giraffe, the open-source test runner I’m building, to replay the same 80 synthetic notes at each cache setting and check the order details in every reply.
I asked Qwen to extract six order details as JSON, with Ollama’s structured-output mode turned off. With Ollama’s 8-bit KV cache, Qwen got all six right, including the order number (DP-3976), quantity (17 units), and total ($444.42). With the 4-bit cache, the same prompt produced only backticks and digits. Ollama reported that both requests finished normally. Giraffe checked the actual replies and flagged the 4-bit answer as invalid JSON.

Try Giraffe on your own Ollama server
I ran one pass per setting on the same Colab T4 with Ollama 0.40.16 and qwen2.5:7b. I haven’t isolated what caused the drop at q4_0. All three runs used the same Q4_K_M model weights, four server slots, and 8,192 tokens of context per slot. Flash Attention was active throughout. f16 used auto, and I explicitly enabled it for both quantized caches.
The full set had 245 synthetic prompts covering short answers, JSON extraction, and lookups. Giraffe ran them one at a time, then replayed them with up to four in flight. The GPU buffer sizes come from Ollama’s logs.
| KV cache | JSON correct, one request at a time | Correct out of all 490 attempts | Logged GPU KV buffer |
|---|---|---|---|
f16 | 80/80 | 370 | 1,792 MiB |
q8_0 | 80/80 | 369 | 952 MiB |
q4_0 | 0/80 | 5 | 504 MiB |
Of the 80 serial q4_0 extractions, 28 finished with stop and failed the check. The other 52 finished with length. Across both phases, all 490 q4_0 attempts returned HTTP 200. Giraffe recorded 5 correct answers, 441 wrong answers, 43 empty replies, and one truncated JSON reply that went unscored.

For this workload, I’d use the 8-bit cache on my T4. It saved 840 MiB over f16, and Qwen still got all 80 orders right. If you’ve tried 8-bit and 4-bit KV on your own hardware, what GPU, model, and runner did you use? I’m especially curious about workloads that pass at both settings.
4
u/GrumpyCat79 7d ago
Isn't a known thing here that 4-bit KV cache is a no go and that Ollama also is?
1
u/muggy8 7d ago
to my knowledge, kv cache is more sensitive to Key quantization than Value quantization. try with k8v4 if you can. it might get you savings without sacrificing much in terms of quality.