BF16 takes half the memory of FP32 while covering the same range of values. That is why training in it usually needs no loss scaling, which FP16 requires, and the weights of many open models are published in BF16.
What a number consists of
| Format | Sign | Exponent | Mantissa | Largest value |
|---|---|---|---|---|
| FP32 | 1 bit | 8 bits | 23 bits | about 3.40e38 |
| BF16 | 1 bit | 8 bits | 7 bits | about 3.39e38 |
| FP16 | 1 bit | 5 bits | 10 bits | 65,504 |
The exponent sets the range; the mantissa sets the number of significant digits. BF16 has the same exponent as FP32, so very large and very small values do not overflow to infinity or underflow to zero. Its mantissa is shorter than that of FP16, giving a precision of roughly two to three decimal digits. Converting from FP32 to BF16 is essentially dropping the lower 16 bits with rounding.
Where it is used
In training, BF16 is used together with FP32: matrix multiplications run in BF16, while sum accumulation and the master copies of the weights stay in FP32. In inference, a BF16 model weighs about 2 bytes per parameter: a 9-billion-parameter model takes about 18 GB. Modern GPUs and processors support the format in hardware; in PyTorch it is torch.bfloat16.
Sources
the term is written from these pagesVerified 18 Nov