Quantisation
Stores weights and activations with fewer bits, such as 8-bit integers.
The idea
Instead of 32-bit floats, map values to a small set of integer levels using a scale and zero-point. Memory drops 4× for int8 and integer arithmetic is faster. Post-training quantisation converts a trained model directly; quantisation-aware training simulates the rounding during training to keep accuracy.
q = round(x / s), x̂ = q · s
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- weight
- allowed value
Full-precision weights: 36 different decimal numbers (32 bits each).
- bits:
- 32
Fewer bits = smaller model but coarser weights. Slide to 1 or 2 bits to see the damage.
Step by step
- 1Choose a bit width and find the value range.
- 2Compute a scale s = range / (2ᵇ − 1).
- 3Round each value to the nearest level: q = round(x / s).
- 4Dequantise (or compute in integers) when running the model.
Where it is used
Running large language models on laptops and phones.
Watch out for
Outlier values and very low bit widths can hurt accuracy.