Rúben GalvãoThe Rabbit Hole

The Rabbit Hole / AI and machine learning / Language models / Running models efficiently

Weight quantisation: could we store the model in fewer bits?

Low-bit weight quantisation, including GPTQ and MXFP4: could nearby weights share fewer stored representations without losing useful behaviour?

In the whole LLM, each projection uses a learned matrix. Those matrices can contain billions of weights. At 16 bits each, a billion weights take about 2 GB, before any other storage.

Most of that space is spent describing the numbers precisely. If a slightly different weight still lets the model do useful work, could we store a simpler approximation?

Trade precision for a smaller set of values

A first attempt would be to round weights to whole numbers. But many weights are small: −0.18 and 0.31 would both become zero, despite starting with different signs and magnitudes.

We do not have to make each integer mean a whole unit. Let it represent a step of 0.1 instead. Now the integer 3 means 0.3, and −2 means −0.2:

weight roundingWhole-number stepsOriginalRounded1-0.72-0.180.310.681-10014roundSteps of 0.1OriginalRounded1-0.72-0.180.310.681-0.7-0.20.30.74round
Whole-number rounding sends −0.18 and 0.31 to the same value, zero. A smaller step preserves more of their differences, while still using small integer codes.

The step size is the scale. With that scale, we can keep a small integer for each weight instead of a separate high-precision fraction. Four bits give us sixteen patterns, enough to encode the signed integers from −8 to 7.

We also need to keep the scale, or those integers would have no fixed meaning. Sharing it across a group of weights avoids storing a new scale for every number:

weight codesOriginal weights1-0.72-0.180.310.68Stored 4-bit codes11001111000110111Rebuilt weights1-0.7-0.20.30.744÷ 0.1, round× 0.1Keep the scale 0.1 once for the group
Four weights share one scale. Their 4-bit codes store the signed integers −7, −2, 3 and 7. Reading them with scale 0.1 gives −0.7, −0.2, 0.3 and 0.7.

Reading the codes with their scale rebuilds an approximate version of the original weights. This is weight quantisation: many possible original values map to a smaller set of stored representations.

The fine scale worked for that group because all its weights were close to zero. A weight of 7 exposes the next problem. With scale 0.1, our largest positive integer, 7, only represents 0.7. We cannot keep the same range and precision with those four bits.

Let smaller groups choose their own range

Increasing the scale to 1 lets us represent the large weight. But try that on [0.1, 0.2, 5, 7]: the small weights disappear into zero again.

The large weights are forcing a coarse step on the small ones. If we split the weights into smaller groups, each group can use a scale suited to its own range:

weight groupsOne group0.10.257scale 100574 weights1Two smaller groups0.10.257scale 1/35scale 10.1140.2574 weights1
The same four weights, using the same 4-bit integer range. Smaller groups give the small weights a finer scale, at the cost of storing another scale.

That gives the smaller weights more useful choices. It also costs another scale. Making every group smaller and smaller would keep adding metadata, eating into the storage saving we wanted.

So a quantised matrix stores codes plus shared scales. Group size balances the rounding error against that extra storage and the way the hardware reads the weights. The matrix still has the same rows and columns:

weight storage16-bit weights4-bit codesQuantise groupsGroup scalesSame matrix shape7,16818,4327,16818,432
A feed-forward projection keeps its rows and columns when quantised. Its stored coefficients use fewer bits, with extra storage for scales. The dimension labels follow the selected model.

Four-bit codes use a quarter of the weight payload of a 16-bit representation. The scales add some bytes back; they do not change the matrix’s input or output width.

Preserve the layer’s behaviour

We have saved storage by changing weights, so the next concern is what happens to the calculation. A change of 0.01 in a weight changes its contribution by 1 when its input is 100, but only 0.01 when its input is 1. The rounding error alone does not tell us how much the model will notice it.

Methods such as GPTQ therefore use example activations to choose quantised weights that keep a layer’s output close to the original. Training or fine-tuning with low precision can also help the model adapt. The resulting model still needs evaluation on its tasks.

There are also better choices than evenly spaced integers for some weights. A small floating-point codebook can put more levels near zero and use wider gaps at larger magnitudes. gpt-oss uses this approach for its routed experts: MXFP4 stores 4-bit floating-point codes with an 8-bit scale for each block of 32 weights.

That block takes 32 × 4 + 8 = 136 bits, or 4.25 bits per weight. Other tensors, including attention weights and embeddings, can remain at higher precision. GPTQ describes a method for choosing weights; MXFP4 describes a storage format.

Using the stored weights still requires applying their scales. Kernels may convert the values as they work or use low-precision hardware directly, so fewer stored bytes do not imply the same reduction in compute time or runtime memory.

These weights describe the learned model. KV cache quantisation tackles a different growing cost: the calculated keys and values kept as the conversation gets longer.

Sources and assumptions

The numeric figures use a simple signed 4-bit integer quantiser, with codes from −8 to 7, to explain rounding and shared scales. They are not an MXFP4 codebook. The examples contain four weights; the matrix diagram uses the selected model’s feed-forward width and token width. It compares storage representations, not a claim that every selected checkpoint was released in both. The visible matrix cells are schematic; weight values and codes remain violet. Two GB uses decimal units. The 4.25-bit calculation covers MXFP4 blocks and scales, not all checkpoint metadata or all model tensors.

← Browse all subjectsBack to the beginning ↑