How the numbers are worked out
The calculator adds three things: the weights, the KV cache, and a runtime allowance.
weights = parameters x bytes per parameter
KV cache = tokens x KV bytes per token
tokens = context length x concurrent sequences
standard / GQA : 2 x layers x KV heads x head dim x bytes
MLA (DeepSeek) : layers x latent dim x bytes
total = (weights + KV cache) x (1 + overhead)
Worked example: a 70B model
Llama 3.1 70B has 70.6 billion parameters, 80 layers, 8 KV heads and a head dimension of 128. In FP8 the weights are 70.6 GB. With an FP16 KV cache each token costs 2 x 80 x 8 x 128 x 2 = 327,680 bytes, so an 8,192-token context adds 2.7 GB for one sequence. With a 10% allowance that is about 80.6 GB, which is just over a single 80 GB card.
What it leaves out
- Speed. Fitting in memory says nothing about tokens per second. Decode is mostly limited by memory bandwidth.
- Interconnect. Splitting a model across chips needs fast links, and the cost depends on the system.
- Training. Gradients, optimiser state and activations multiply the requirement. This is inference only.
- Unified memory. On Apple silicon and similar parts the operating system shares the pool, so usable capacity is lower than the headline figure.
- Mixture-of-experts. All experts must be resident, so total parameters count, not the active subset.
Questions
How much GPU memory does a 70B model need?
For 70.6B parameters the weights alone are about 141 GB in FP16, about 71 GB in FP8 or INT8, and about 40 GB in 4-bit group quantisation. The KV cache and overhead come on top.
What is the KV cache?
While generating, the model keeps the attention keys and values of every earlier token so it does not recompute them. It grows with context length and with the number of concurrent requests, and at long contexts or high concurrency it can exceed the weights.
Does this cover training?
No. Training needs far more memory per parameter. This tool is for serving a model.
Does a model that fits run fast?
Not necessarily. Capacity decides whether it fits; bandwidth and interconnect decide how quickly it runs.