How is KV cache VRAM calculated?
For standard Grouped-Query Attention (GQA) models, KV cache bytes equal 2 * layers * kv_heads * head_dim * bytes_per_element * context_length * batch_size. DeepSeek-R1 uses Multi-Head Latent Attention (MLA), shrinking KV cache to ~0.07 MB/token.
How much VRAM does Q8_0 or Q4_0 KV cache save?
Quantizing the KV cache from FP16 to Q8_0 cuts KV memory by ~47% with negligible quality impact, while Q4_0 cuts KV memory by ~72% for 64K-128K contexts.
Why does partial CPU offload drop tok/s so sharply?
When model layers spill from 1,000+ GB/s GPU VRAM into ~50-80 GB/s DDR5 system RAM over PCIe, sequential token generation becomes bottlenecked by the slowest offloaded layers.