Renaissance LabsLearn

Capabilities · Efficiency

Memory footprint

The model fits on the hardware you have.

1Where it comes from

DesignMost
Pre-trainingNot here
Fine-tuningNot here
PreferencesNot here
RLNot here
DeploymentMost
Design and pre-training

Parameter count and number format set the size. Both are design choices.

Post-training and deployment

Quantisation after training shrinks the model. Distillation moves the ability into a smaller one.

2How to work it out

Three things take memory: the weights, the cache for the context, and, in training, everything the optimizer keeps. Each one is a multiplication.

The weights

Weights

memory = parameters x bytes per parameter

A 9-billion-parameter model:

32-bit 4 bytes 36 GB

16-bit 2 bytes 18 GB

8-bit 1 byte 9 GB

4-bit 0.5 byte 4.5 GB, plus a little for the block scales

The cache for the context

While it writes, the model keeps a key and a value for every earlier token, in every layer. A rough size per token:

Context cache

bytes per token = 2 x layers x KV heads x head size x bytes per number

Assume 36 layers, 8 KV heads, a head size of 128 and 16-bit numbers:

2 x 36 x 8 x 128 x 2 = about 147 KB per token

A 32,768-token context: about 4.8 GB, for one conversation

The head count and head size here are assumptions for the example. Read the real ones from the model's config file. Every request served at the same time needs its own cache, so this number is multiplied by the number of users.

Training

Training keeps much more per weight: the gradient, the optimizer's running averages, and often a full-precision copy of the weights. A common rule of thumb for mixed-precision training with Adam is about 16 bytes per parameter.

Full fine-tuning

9 billion x 16 bytes = 144 GB, before activations

That does not fit on one accelerator, which is why full-weight fine-tuning of a 9B model runs across several GPUs. Activations come on top and grow with batch size and sequence length. The rule is rough: real setups differ by optimizer and recipe.

What fits where

AcceleratorMemory
NVIDIA A10040 or 80 GB
NVIDIA H10080 GB
NVIDIA H200141 GB
NVIDIA B200Up to 192 GB
AMD MI250X128 GB, as two dies of 64 GB
AMD MI300X192 GB
AMD MI325X256 GB

A 9B model at 16 bits, with a 32K context, needs about 23 GB and fits on any of these. At 4 bits it fits in under 10 GB.

How to shrink it

LeverWhat it shrinksWhat it costs
Fewer bits per weightWeightsA small loss of accuracy, most at 4 bits
A distilled, smaller modelWeights and cacheThe student does not match the teacher everywhere
Shared key and value headsCacheDecided in the design
Low-rank adaptersTraining memoryOnly a small set of added weights is trained

What to report

  1. Parameters and bits per weight.
  2. Context length used, and how many requests at once.
  3. Peak memory measured, not only the calculated one.
  4. Benchmark scores before and after any change in precision.

Parameters, precision and memory goes through the formats, and Distillation and quantization covers the two ways to shrink a model.

3How to measure it

  • Size in memoryParameters times bytes per parameter, plus the cache for the context. State the precision and the context length.
  • Accuracy after quantisationThe same benchmarks, before and after.

4Common datasets and methods

No datasets listed yet.

If your lab has a dataset for this, add it and it appears here.

Add one

5Recipes

No recipes yet.

If your lab has a training run that improves this, add it and it appears here.

Add one

6Findings

7Wanted

  • Before and after scores for 4-bit versions of open European models.I have this

8Read more