Inference and Serving, lesson 14
Number formats
What FP32, BF16, FP8, INT8 and INT4 each keep and lose.
You know a model is billions of stored numbers, and from "Arithmetic intensity" that decode spends most of its time reading them.
Part 1. Sign, exponent, mantissa
Scientists write 6.5 as 1.625 × 2². Computers store decimals the same way, in three parts: a sign (plus or minus), a power of two, and the digits that get multiplied by it. Here is 6.5 in a 16-bit format.
Example 1.1
Reading 6.5 out of 16 bits
- 0100011010000000
16 bits, split 1, 5 and 10.
- 0→positive
The first bit is the sign. 0 means plus.
- 10001=1717−15=2→× 2²
The next 5 bits give a power of two. They're stored with 15 added, so negative powers fit too.
- 1010000000→1.101 in binary1+0.5+0.125=1.625
The last 10 bits are the digits after the point. A leading 1 is assumed and never stored.
- 1.625×4=6.5
Put them together and you get the number back.
Exponent and mantissa
The exponent bits pick a power of two, so they set the range: how big or how small a number can get. The mantissa bits are the digits, so they set the precision: how finely you can tell nearby numbers apart. Floating point formats differ only in how many bits go to each.
Your turn
In that format (FP16), what's the gap between 1.0 and the next number up? The mantissa has 10 bits.
Part 2. Range against precision
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Range against precision
- Integers need a scale
- What a model weighs
Inference and Serving overviewSpotted a mistake? Tell us.