128k context on a desktop is a lease: the KV cache is the bill
128k context on a desktop is a memory lease: Llama 3.1 8B's KV cache hits ~16 GiB at 131,072 tokens, as big as the weights — a 32 GiB problem. 128 KiB per token, allocated up front.
128k context on a desktop is a memory lease. Llama 3.1 8B at 131,072 tokens, fp16, bills a KV cache of about 16 GiB — as big as the weights. The "8B that fits in 16 GiB" becomes a 32 GiB problem.
GiB of KV cache at full 128k — the cache equals the weights, so the 8B becomes a 32 GiB tenancy.
Allocated up front, linear in context. RAM pays for 128k whether or not you fill it.
How much memory does 128k context cost?
One public formula drove every number on the meter:
cache_bytes = 2 × layers × context × kv_heads × head_dim × bytes_per_element
def kv_cache_gib(layers, kv_heads, head_dim, ctx, bytes_per=2):
return 2 * layers * ctx * kv_heads * head_dim * bytes_per / 2**30kv_cache_gib(32, 8, 128, 131_072) # Llama 3.1 8B -> 16.0kv_cache_gib(28, 4, 128, 131_072) # Qwen2.5 7B -> 7.0
| Model (fp16) | Layers × KV heads | Cache @ 128k | Weights | Cache vs weights |
|---|---|---|---|---|
| Llama 3.1 8B | 32 × 8 | ~16 GiB | ~16 GiB | ~100% |
| Qwen2.5 7B | 28 × 4 | ~7 GiB | ~15 GiB | ~47% |
Fewer KV heads, thinner cache — grouped-query attention, architecture not quantization. The heads hide in config.json.
where the bill bends
Prefill: a 100k-token prompt is chewed before the first output — minutes on a 3060. Sliding-window: mistral-style attention caps per layer; the formula overestimates them, in your favor. KV quantization: llama.cpp's q8_0 roughly halves the cache; half of 16 GiB is still 8 GiB. Serving: vLLM takes GGUF on GPU with the same bill — quantization shrinks weights, never cache math.
Nobody reads 128,000 tokens. Your RAM pays for every one of them anyway.
- recorded 2026-09-22, refreshed 2026-10-04 — fp16, 131,072-token window
- Llama 3.1 8B · Qwen2.5 7B — public config.json (layers, KV heads, head_dim)
- formula from Transformer Inference Arithmetic; the meter is that same formula in JavaScript — no benches, one print from your terminal