KV cache & memory-fit calculator
Compute the KV cache per token, per sequence and per batch for Llama, Qwen, DeepSeek, Mixtral and gpt-oss, or a custom architecture, then check whether weights plus cache fit on a chosen GPU. Formula shown with every result.
Model
70.6B params · 80 layers · 8 KV heads × 128 head dim
Workload
Hardware
- KV per token
- 2 × 80 × 8 × 128 × 2 B = 328 KB
- KV total
- 328 KB × 8,192 × 32 = 85.9 GB
- Weights
- 70.60B × 2 B = 141 GB
- Free for KV
- 80.0 GB − weights − 10% = -69200000000.0 B
What the interviewer is actually asking
The serving loop's opening question is some version of "will this fit, and for how many users?" The answer is two multiplications and a subtraction, and the interviewer is listening for whether you reach for the KV cache unprompted, whether you know that grouped-query attention is what makes 70B serviceable, and whether you leave headroom for the allocator.
Questions people ask
Per token: 2 × layers × KV heads × head dimension × bytes per element. Multiply by context length for one sequence and by the number of concurrent sequences for the batch. Llama 3.1 70B in bf16 is 2 × 80 × 8 × 128 × 2 = 320 KB per token, so an 8k-token sequence holds about 2.6 GB of cache.
