How much memory does a 70B model need?

Work out the memory a language model needs from its parameter count: weights, quantization and the context cache, with the arithmetic for Llama 3.1 70B.

Popo
On this page

Before downloading a model to run on your own hardware, you can work out whether it will fit. Two things need memory: the model's parameters, which is a fixed amount, and the conversation, which grows with its length.

Weights: parameters × bytes

The rule is one multiplication. Most models are published with 16-bit numbers, which take 2 bytes each. Llama 3.1 70B has 70,553,706,496 parameters, so:

Terminal
python3 -c "print(70_553_706_496 * 2 / 1e9, 'GB')"141.107412992 GB

That's more than any single consumer graphics card holds. Storing each parameter in fewer bits, called quantization, shrinks it in proportion:

Llama 3.1 70B, weights only

16-bit2 bytes per parameter141.1 GB
8-bit1 byte70.6 GB
4-bithalf a byte35.3 GB
Calculated from the exact parameter count, in GB of 10⁹ bytes. Real quantized files are a little larger because they also store scaling factors, and usually keep some parts at higher precision.

A shortcut: at 8 bits, the number of billions is the number of gigabytes. Double it for 16-bit, halve it for 4-bit.

Parameters16-bit8-bit4-bit
8B16 GB8 GB4 GB
32B64 GB32 GB16 GB
70B140 GB70 GB35 GB
405B810 GB405 GB203 GB
671B1,342 GB671 GB336 GB
Weights only, rounded. 671B is the size of DeepSeek-V3; although it uses 37B parameters per token, all of them have to be in memory.

What quantization costs

Rounding the parameters loses detail. In general, 8-bit versions behave much like the original, 4-bit versions lose some quality, and below that the loss becomes easy to notice. How much depends on the model, the method and the task, so test on your own work instead of trusting a single benchmark number.

Between a smaller model at high precision and a larger one at low precision of the same memory size, there's no universal winner. They're the two to compare.

The conversation: the key-value cache

While reading and writing, the model keeps the keys and values of every token so far, so it doesn't have to compute them again. This KV cache grows with every token. Its size also follows from the published dimensions. For Llama 3.1 70B: 80 layers × 8 key-value heads × 128 numbers × 2 (key and value) × 2 bytes:

Terminal
python3 -c "per_token = 80 * 8 * 128 * 2 * 2print(per_token / 1024, 'KiB per token')print(per_token * 131072 / 1024**3, 'GiB at 131,072 tokens')"320.0 KiB per token40.0 GiB at 131,072 tokens

Extra memory for the conversation, Llama 3.1 70B

8,192 tokens2.5 GiB
32,768 tokens10 GiB
131,072 tokens40 GiB
Calculated at 16 bits for one conversation; a server handling several needs one cache for each. Many programs reserve the whole amount for the context length you set when they start.

Other models differ: the number of layers and key-value heads is in each model's config.json, as num_hidden_layers and num_key_value_heads. DeepSeek-V3 uses a different design that compresses the cache, so this formula doesn't apply to it.

This explains a common surprise: a model that loads fine and then runs out of memory in a long chat. Setting a shorter context is often the easiest fix.

Adding it up

Weights + cache + a margin for the software itself. For a 4-bit 70B model with 8,192 tokens of context: 35.3 GB + 2.7 GB (2.5 GiB) ≈ 38 GB, before the margin.

Then look at where the memory is. Speed depends mostly on how fast the memory can be read, because every token requires reading all the active weights. As an upper bound, tokens per second can't exceed memory bandwidth divided by the size of the weights used. With 35 GB of weights, memory that reads 100 GB per second can't produce more than about 3 tokens per second in one conversation, whatever the processor.

If a model doesn't fit on the graphics card, software can split it with ordinary memory. It runs, but at the pace of the slower part.