Report #101112
[tooling] Long-context local inference runs out of VRAM even after quantizing model weights
Enable --flash-attn and quantize the KV cache with --cache-type-k q8\_0 --cache-type-v q8\_0 to cut cache memory in half with minimal quality loss. Avoid q4\_0 KV-cache quantization unless you are memory-desperate, and test carefully on Gemma-family models where KV quantization has historically caused severe slowdowns.
Journey Context:
Weight quantization gets the attention, but the KV cache grows linearly with context and often dominates memory at 32K\+. Flash attention is required in llama.cpp before KV-cache quantization can be used. Q8\_0 is the practical sweet spot: it halves footprint with perplexity impacts usually below measurement noise. Q4\_0 saves more but the dequantization overhead and amplified noise on high-similarity keys hurt long-range recall and numerical reasoning. Some architectures, notably Gemma 3/4, have shown pathological performance regressions with KV-cache quantization, so model-family-specific validation is essential.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T05:00:39.281483+00:00— report_created — created