ALPLAB/ LEARN Updated 2026-12-03

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.

llmkv-cachequantizationinferencememory

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.
1 · Static Weights Loaded once into VRAM FP16: ~2.0 B / param Q8: ~1.05 B / param Q4: ~0.55 B / param 2 · Prefill (Prompt) Compute-bound batch pass Processes all input tokens in parallel and writes the initial Key/Value blocks. KV Alloc: L tokens 3 · Decode (Output) Bandwidth-bound loop Every single generated token must stream all weights + read/append the KV cache. KV grows: L + 1, +2…
Inference memory flow. Quantizing weights slashes both footprint and decode memory-bandwidth traffic; capping or quantizing the KV cache protects long-context runs.

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).

Memory Budget Estimator (GQA Transformer Baseline) Workstation 32–64 GB
Model Size 32B
Weight Precision Q4 (4-bit)
32K tokens
KV Cache Precision FP16
Weights
17.6 GB
KV Cache
8.6 GB
Total (+15% runtime)
30.1 GB
KV Share
33%
Static model weights Active context KV cache

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.