Why Model Size Isn't Memory Size: Weights, KV Cache, and Quantization
How parameter count, weight precision, and context length combine to decide what hardware a language model actually requires.
Parameter count gets all the headlines — 8B, 32B, 70B — yet hardware requirements during real inference regularly surprise engineers. A "small" 14B model can overflow a 24 GB GPU at 128K context, while a quantized 70B model can fit comfortably on a high-memory workstation at short context.
To size hardware accurately, separate memory into two distinct budgets: static weights (paid once when loading the checkpoint) and the dynamic KV cache (which grows linearly with every token in the active conversation).
1. The two memory budgets inside an LLM
- Model weights stay fixed after load. At
FP16(2 bytes/parameter), a 32B model occupies ~64 GB before runtime overhead. Quantizing to 4-bit (Q4, ~0.55 bytes/parameter including scale blocks) shrinks weights nearly 4× to ~17.6 GB. - KV cache stores the attention Keys and Values for every past token across every transformer layer so tokens are not recomputed from scratch on each step.
2. Interactive Memory & Hardware Tier Explorer
Adjust parameter count, weight quantization, context length, and KV-cache precision below to see how quickly context length shifts the required hardware tier (assuming modern Grouped-Query Attention with 8 KV heads).
3. Practical sizing rules of thumb
- Quantization helps decode speed as well as size: Autoregressive generation is usually memory-bandwidth-bound. Moving a 32B model from FP16 (64 GB) to Q4 (~18 GB) gives nearly 3–4× fewer bytes streamed per output token.
- Long context flips the bottleneck: Notice in the estimator above that pushing an 8B Q4 model from 4K to 128K shifts memory from ~5 GB (fits anywhere) to ~24+ GB (exceeds a 16 GB laptop budget) unless the KV cache is quantized or compacted.
- Architectural multipliers matter: Models with Grouped-Query Attention (GQA) or Multi-Head Latent Attention (MLA) shrink the KV cache by 4–8× relative to older Multi-Head Attention architectures — check the architecture, not just the parameter count.