GPU memory: weights + KV cache
Pick a model, precision, context and batch, and see what fits in one 80 GB GPU.
Weights are a fixed cost; the KV pool is what you sell: 74 GB left → 27 sequences of 8k tokens. Halve the context or store KV in FP8 and that number ≈ doubles.
How it's calculated · assumptions
KV/token = 2 × layers × kv_heads × head_dim × bytes = 2 × 80 × 8 × 128 × 2 B = 320 KiB
max batch = ⌊(usable memory − weights) ÷ (KV/token × 8k)⌋ = 27
Shapes: Llama 3 paper, Table 3: 32 / 80 layers, 8 KV heads, head_dim = 4096 ÷ 32 = 8192 ÷ 64 = 128 (arXiv 2407.21783, checked 2026-11-17). Nominal 8B / 70B parameters, decimal GB. Ignores activations, CUDA graphs, fragmentation and quantization scales (a few GB per GPU in practice; the concept's worked example assumes 4 GB), so treat every result as a ceiling. A100 and H100 hold the same 80 GB: they differ in bandwidth (~2 vs ~3.35 TB/s on H100 SXM), not in what fits.