Picture a giant dictionary where every word is defined to ten absurd decimal places. Quantization is the art of rounding those definitions intelligently so they fit in a pocket-sized format without losing meaning. Applied to AI, it lowers the numerical precision of a model's weights — moving from 32-bit floating point (FP32) to 8-bit integers (INT8) or fewer — to shrink memory and speed up computation.
The principle: fewer bits, same knowledge
A large language model stores billions of weights. In FP32 each weight takes 4 bytes; in INT8, just one. Quantization maps a range of real values onto an integer range via a scale factor:
$$ x_q = \text{round}\left(\frac{x}{s}\right) + z $$
where $s$ is the scale and $z$ the zero-point. The model "thinks" almost the same, but weighs far less.
The size / accuracy trade-off
| Format | Bits | Relative memory | Quality loss |
|---|---|---|---|
| FP32 | 32 | 100% | none (reference) |
| FP16 | 16 | 50% | negligible |
| INT8 | 8 | 25% | low |
| INT4 | 4 | 12.5% | moderate |
Why it matters
- Cost: a quantized model fits on a smaller GPU, even a phone.
- Speed: integer operations run faster.
- Access: democratizes AI for budget-conscious Moroccan startups.
We distinguish post-training quantization (fast, applied after the fact) from quantization-aware training (QAT), which simulates the precision loss during learning to compensate for it.
Quantization trades precision you don't need for efficiency you desperately do.