Why AI Uses Different Number Precisions
See how storing numbers with fewer bits saves memory and gains speed, and what each bit is for.
Every lesson so far has ended at the same bottleneck: moving bytes. So here’s a tempting idea. What if each number simply took up fewer bytes?
Computers store decimal numbers as floating point, a kind of scientific notation in binary. Each number has three parts: a sign (plus or minus), an exponent (how big: is this 0.001 or 1,000,000?) and a mantissa (the digits themselves). The classic format, FP32, spends 32 bits, 4 bytes, on every number.
Neural networks turn out to be remarkably relaxed about rounding. A weight of 0.4183 or 0.42 barely changes the answer, so modern AI mostly uses 16 bits, and increasingly 8 or even 4. Halve the bits and you halve the memory, halve the bytes to move (straight relief for the memory wall) and, on the right hardware, double the maths speed.
The trick is choosing which bits to give up. Exponent bits buy range: with too few, big numbers overflow into “infinity” and tiny ones vanish to zero. Mantissa bits buy precision: with too few, nearby numbers blur together. Look at the two 16-bit formats in the picture. FP16 keeps more digits but tops out at 65,504. BF16, designed at Google for deep learning, keeps FP32’s full range and gives up digits instead, because training is wrecked by an overflow but shrugs off a little blur. That’s why BF16 became the workhorse.
Go below 8 bits and floating point runs out of room, so models switch to integers with a scale factor: the quantization you met at the end of Track 2. The next lesson shows the special hardware that turns all these smaller numbers into raw speed.
Key takeaways
- A floating-point number has a sign, an exponent (range) and a mantissa (digits).
- BF16 has FP32’s range with fewer digits; FP16 has more digits but a much smaller range.
- Halving the bits halves the memory and the data to move, and roughly doubles tensor-core speed.
- Below 8 bits, models switch to scaled integers (INT8, INT4): great for running, with a small loss of accuracy.
Check your understanding
Go deeper (more technical)
- FP32: 1 sign, 8 exponent, 23 mantissa bits. About 7 decimal digits.
- BF16: 1 / 8 / 7. Same range as FP32, about 2–3 digits.
- FP16: 1 / 5 / 10. Max 65,504, about 3–4 digits.
- FP8 E4M3: 1 / 4 / 3, max 448. FP8 E5M2: 1 / 5 / 2, max 57,344.
- INT8 / INT4: integers with a scale factor (here one scale for the range ±10; real methods use per-channel or per-group scales).
Training typically uses mixed precision: the maths runs in BF16 (or FP8), but an FP32 “master copy” of the weights accumulates the tiny updates, which would otherwise round away to nothing. Inference often runs in BF16, FP8 or 4-bit formats.
The simulation rounds to nearest and ignores subnormal and special-value details.