How much VRAM does context length use?
The KV cache grows linearly with context. For Llama 3.1 8B Instruct each token costs about 0.131 MB at f16, so 32k context adds about 4.3 GB and 128k about 17.2 GB (est.). A q8_0 KV cache halves it; q4_0 cuts it to about a quarter.
Checked 2026-10-22 · memory figures are estimates
KV cache for Llama 3.1 8B Instruct (est.)
| Context | f16 | q8_0 | q4_0 |
|---|---|---|---|
| 4k | 0.54 GB | 0.29 GB | 0.15 GB |
| 8k | 1.07 GB | 0.57 GB | 0.30 GB |
| 32k | 4.29 GB | 2.28 GB | 1.21 GB |
| 64k | 8.59 GB | 4.56 GB | 2.42 GB |
| 128k | 17.18 GB | 9.13 GB | 4.83 GB |
How we got this number
KV cache = 2 (keys and values) × layers × KV heads × head dimension × context × bytes per element. Llama 3.1 8B Instruct has 32 layers, 8 KV heads and head dimension 128 (config.json), so f16 at 32k is 2 × 32 × 8 × 128 × 32768 × 2 bytes ≈ 4.3 GB. Models with sliding-window or MLA attention need less; the checker handles those.
Llama 3.1 8B Instruct page · Try a context length in the checker
FAQ
Q4 vs Q8 KV cache: which should I use?
q8_0 halves KV memory and is the usual first step. q4_0 saves more but may cost more quality; we haven't measured that. Set it in llama.cpp with -ctk and -ctv.
How much VRAM does 256k context use?
It depends on the architecture. Models with few KV heads or hybrid attention need far less per token. Pick the model and 256k in the checker to see the estimate.
Does context change which quant fits?
Yes. A model that fits at 8k can fail at 128k, so the checker and What fits pages always state the context they assume.
Open the checker · What fits my GPU?
More short answers
- What LLM can I run on my GPU?
- How much VRAM do I need for a 70B model?
- Is 16GB RAM enough to run an LLM locally?
- MLX vs GGUF on a Mac: which is faster?
- How much VRAM do I need for a 7B model?
- How much VRAM do I need for a 32B model?
- Is 12GB VRAM enough for local LLMs?
- Can you run an LLM on CPU only?
- Q4 vs Q8: which quantization should I use?
Will It Run? Pro NOT BUILT YET
A personal setup for your exact hardware (Ollama / llama.cpp configs ready for your coding agent), an alert when a new model fits, and a one-click cloud fallback when it doesn't.
Not built yet. Join the waitlist, $10/mo planned, no charge now. What's planned
Email only. No payment info.