Add 1.0 to a bfloat16 counter a thousand times. The answer is 256.
Not 1000, not "about 1000". Exactly 256. I ran it on my laptop (PyTorch 2.10, CPU) and the counter stops at 256 and never moves again. Then I summed 4,096 random numbers between 0 and 1. The true total is about 2,020. A bf16 accumulator says 256.
bf16 is the default weight format for most open LLMs. Here is the whole format in one picture and a handful of measured experiments, so you know what it keeps, what it throws away, and where it bites.
The picture
fp32: S EEEEEEEE MMMMMMMMMMMMMMMMMMMMMMM (1 + 8 + 23 bits) bf16: S EEEEEEEE MMMMMMM (1 + 8 + 7 bits) \_______________/ bf16 = the top 16 bits of fp32, rounded
Enter fullscreen mode
Exit fullscreen mode
bf16 keeps the sign and all 8 exponent bits of fp32 and only the top 7 stored mantissa bits. With the implicit leading 1, that is 8 significant bits. Converting fp32 to bf16 means dropping the low 16 bits, with rounding.…