Quantization

Reducing numeric precision in a model to save memory and speed up inference.

What disappears when weights share a grid?

Take an illustrative quantizer with scale 0.1, zero point 0 and enough integer range to hold these values. Divide a weight by the scale and round to the nearest integer. Multiply by the scale to reconstruct its approximate value.

Original weightStored integerReconstructed weight
0.2320.20
0.2420.20
−0.31−3−0.30

Where does the tradeoff appear?

The first two weights become indistinguishable. Smaller representations can reduce memory traffic and may speed up inference on hardware with suitable kernels. The result depends on which weights and activations are quantized, the scale choices and the implementation.

A continuous blue gradient is displayed above a strip of discrete swatches.
Mapping many nearby values to the same level saves representation space at the cost of detail.

How much space did the model save?

One million values occupy four million bytes at 32 bits each or one million bytes at eight bits each before scales, offsets and other storage. Check the actual deployed file, measured latency and task performance. A fourfold reduction in the raw weight array does not imply a fourfold reduction in end-to-end latency.

Follow the idea

Inference · Measure the prediction path in which quantized values are used.

Model Evaluation · Test whether altered outputs still meet the task’s needs.

Source · Jacob and colleagues on integer quantization for efficient inference

Return to Quantization in the A–Z glossary