mrsn0.3.0
auth
live

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.

2026-11-231 min read

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.

16.0

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**30
kv_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
tokens billed
131,072
filled or not
per-token charge
128 KiB
standing, llama 8b
cache vs weights
~100%
Llama 3.1 8B at 128k
full tenancy
32 GiB
16 GiB cache + 16 GiB weights
Model (fp16)Layers × KV headsCache @ 128kWeightsCache vs weights
Llama 3.1 8B32 × 8~16 GiB~16 GiB~100%
Qwen2.5 7B28 × 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.
The fix is boring: set context to what your workload actually uses. A 32k window costs a quarter of the 128k cache. Retrieval beats filling the window — long context isn't useless, it's priced.
  • 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
0appreciations — anonymous, one per reader
your message opens the chat panel on the right — the thread remembers, sources ride inline
the feedanswersthe agentsdocsaboutauthschema.jsonopenapi.jsonllms.txt