4 July 2026
Floating-Point Precision in LLMs
When I started reading about LLM training and serving, I kept seeing FP32, FP16, BF16, FP8, INT4 and FP4 everywhere. At first I thought it was simple: more bits means better. It turns out that in LLMs the real trade-off is between range, precision, memory, speed and training stability. Today I want to figure out what each format is actually for.
Why it matters
LLMs are mostly huge matrix multiplications. The number format you choose changes:
- whether training overflows or underflows
- how much GPU memory the weights, activations, gradients and optimizer states take
- how fast tensors move through memory bandwidth
- how many users one GPU can serve
- whether a quantized model still keeps its quality
This is why BF16 matters for training and INT4/FP4 matter for inference.
How a floating-point number is stored
A float is binary scientific notation:
(-1)^sign * 1.mantissa * 2^exponent
Each field has its own job:
| Field | Job |
|---|---|
| Sign | positive or negative |
| Exponent | how big or small the number can be (range) |
| Mantissa | how finely you can tell nearby numbers apart (precision) |
The common layouts:
| Format | Bits | Sign | Exponent | Mantissa | Trade-off |
|---|---|---|---|---|---|
| FP32 | 32 | 1 | 8 | 23 | stable, expensive |
| FP16 | 16 | 1 | 5 | 10 | more precision than BF16, much smaller range |
| BF16 | 16 | 1 | 8 | 7 | same range as FP32, less precision |
The interesting part: FP16 has more mantissa than BF16, but BF16 keeps FP32's exponent. In training, range usually matters more than a few extra mantissa bits, because a value that overflows to infinity or underflows to zero can break the whole optimization.
Why BF16 works for training
Neural networks can live with some rounding noise. What they cannot live with is values silently blowing up or vanishing. BF16 halves memory compared with FP32 and still keeps the range that gradients and activations need. (BF16 means Brain Floating Point, from Google Brain. Nothing to do with biology.)
In practice nobody uses one format for everything. A real training stack is mixed precision:
- BF16 for activations and matmul inputs
- higher precision for the accumulation inside the kernels
- FP32 for optimizer states and master weights
Why inference can go lower
Inference has no backward pass and no optimizer state, so we can push the weights down to 8 or 4 bits. For a 70B model, the raw weights alone take roughly:
| Precision | Raw weight memory |
|---|---|
| FP32 | 280 GB |
| FP16 / BF16 | 140 GB |
| FP8 / INT8 | 70 GB |
| FP4 / INT4 | 35 GB |
These numbers are only the weights. Real serving also needs the KV cache, activations, scaling factors and runtime buffers.
INT4 vs FP4
INT4 uses evenly spaced integer levels plus a scale. FP4 uses floating-point style levels, so it can follow some value distributions more naturally. But "FP4" is not one single standard: the layout, block size, scaling rule and hardware support all change how it behaves.
Is FP4 training a thing?
Not in the "everything is FP4" sense. Four bits are too few for small gradients and small updates. Low-bit training systems keep higher precision somewhere: higher-precision accumulation, BF16 gradients, FP32 optimizer states, blockwise scaling, stochastic rounding or FP32 master weights.
Things I got confused about
- FP16 is not automatically better than BF16 just because it has more mantissa bits. Its smaller range makes training fragile.
- Memory tables for FP4/INT4 usually mean the raw weights only.
- "FP4 training" usually does not mean the whole pipeline runs in FP4.
A small exercise
Try converting 10.625 into binary, normalise it as , then write down its sign, biased exponent and mantissa in FP32 and FP16. After that it becomes obvious why BF16 keeps FP32's exponent but drops mantissa bits.
What I want to try next
- Check the FP8 formats (E4M3 and E5M2) against hardware docs.
- Run a tiny FP32 / FP16 / BF16 training comparison and record how stable the loss is.