Everything is bits
Computers store everything as bits: tiny switches that are either 0 or 1. One bit can tell two things apart. Two bits give four patterns (00, 01, 10, 11). Every extra bit doubles the number of patterns.
| Bits | Different values | Example |
|---|---|---|
| 1 | 2 | yes or no |
| 4 | 16 | the 4-bit weights of a squeezed model |
| 8 (one byte) | 256 | one letter of English text |
| 16 | 65,536 | the weights of most released models |
| 32 | about 4.3 billion | the numbers in most ordinary software |
Eight bits make a byte, the unit for file sizes. A gigabyte (GB) is a billion bytes. That gives the most useful rule in this course: a model’s size in bytes is its number of weights times the bits per weight, divided by 8.
Floating point: scientific notation in binary
Whole numbers are easy to store, but model weights are numbers like 0.0213 or −1.7. For these, computers use floating point, the same idea as scientific notation. Light travels about 3.0 × 10⁸ metres per second: one part gives the digits (3.0), the other says where the decimal point goes (10⁸). That lets the same few digits describe both huge and tiny numbers.
A floating-point number splits its bits into three parts:
- Sign (1 bit): plus or minus.
- Exponent: the power of 2, which sets how big or small the number is. More exponent bits mean a wider range.
- Fraction (also called the mantissa): the digits. More fraction bits mean more precision, so less rounding.
value = ± 1.fraction × 2^(exponent − bias)The bias is a fixed number that lets the exponent go negative, for very small values.
−2.5 = − 1.25 × 2¹Sign minus, exponent 1, fraction .25 (in binary .01).
A surprising result: floating-point numbers are not evenly spaced. There are as many of them between 1 and 2 as between 1,024 and 2,048. Near zero they are packed very tightly; for big numbers the gaps are wide. That suits neural networks well, because most weights are small numbers close to zero.
Type any number, or pick one, and see what each format actually stores, the rounding error, and the bits themselves. Try 70000 (too big for FP16), 0.1 (no format stores it exactly) and 1000 (too big for FP8).
This interactive part needs JavaScript.
The formats AI uses
| Format | Bits: sign, exponent, fraction | Largest value | Used for |
|---|---|---|---|
| FP32 | 1 + 8 + 23 = 32 | about 3.4 × 10³⁸ | Ordinary software; sums inside training that need extra care |
| FP16 | 1 + 5 + 10 = 16 | 65,504 | Older GPUs. Precise, but its small range overflows easily |
| BF16 | 1 + 8 + 7 = 16 | about 3.4 × 10³⁸ | The standard for training and for releasing weights today |
| FP8 E4M3 | 1 + 4 + 3 = 8 | 448 | DeepSeek-V3 was trained in it; DeepSeek-V4 and GLM-5.3 release weights in it |
| FP4 E2M1 | 1 + 2 + 1 = 4 | 6 | Only 15 different values; usable for weights when blocks share a scale |
BF16 (“brain float”, from Google Brain) is the clever one. It keeps FP32’s 8 exponent bits, so it has the same huge range, and gives up fraction bits instead. Training rarely needs 7 exact digits, but it hates numbers that suddenly overflow to infinity. FP16 has the opposite trade-off, which is why training in FP16 needed tricks to keep numbers in range, and why BF16 replaced it.
Why keep cutting bits? Three reasons, and you already know two. Fewer bits mean a smaller file and less memory to read for every token, so text comes out faster. And GPUs do more sums per second with smaller numbers: on Nvidia’s H100, FP8 maths runs about twice as fast as BF16.
Quick check
Sharing a scale: how 4 bits can be enough
FP4 has only 15 values: 0, ±0.5, ±1, ±1.5, ±2, ±3, ±4 and ±6. Real weights are numbers like 0.0213. How can that possibly work? With one trick that runs through all of model compression: blocks that share a scale.
- Cut the weights into small blocks, for example 32 weights in a row.
- For each block, store one scale: a number that the whole block is multiplied by.
- Store each weight as a tiny number (4 bits) that, times the scale, comes close to the real weight.
- Because weights next to each other tend to have similar sizes, one scale fits the whole block well.
| Format | Block | Bits per weight |
|---|---|---|
| MXFP4 | 32 FP4 values + one 8-bit power-of-two scale | 4 + 8 ÷ 32 = 4.25 |
| Q4_ | 32 four-bit whole numbers + one 16-bit scale | 4 + 16 ÷ 32 = 4.5 |
| Q8_ | 32 eight-bit whole numbers + one 16-bit scale | 8 + 16 ÷ 32 = 8.5 |
That is why you see sizes like 4.25 or 8.5 bits per weight: the scale’s bits are shared out across the block.
OpenAI released gpt-oss with its expert weights in MXFP4, so the 20.9-billion-parameter model is a 12.1 GB file. That works out at about 4.6 bits per weight overall, because the attention weights and embeddings are kept at higher precision. Moonshot went further with Kimi K3: it taught the model to cope with MXFP4 during its later training stages (this is called quantization-aware training), so the 4-bit weights are the native release, not a squeezed copy. The quantization lesson in part 6 goes much deeper.
From bits to gigabytes
bytes = parameters × bits per weight ÷ 88 billion × 16 ÷ 8 = 16 GBLlama 3.1 8B in BF16.
8 billion × 8.5 ÷ 8 = 8.5 GBThe same model in Q8_0.
8 billion × 4.5 ÷ 8 = 4.5 GBIn Q4_0: small enough for most laptops.
1.6 trillion × 8 ÷ 8 = 1.6 TBDeepSeek-V4-Pro in FP8: far too big for a laptop, so data centres spread it across many GPUs.
FP16’s largest value is 65,504. Which of these numbers can it store?
-
1,000
Answer: Fits in FP16
-
70,000
Answer: Too big
-
0.5
Answer: Fits in FP16
-
65,000
Answer: Fits in FP16
-
1,000,000
Answer: Too big
-
−3.75
Answer: Fits in FP16
Remember
- n bits hold 2ⁿ different values: 4 bits give 16, 8 bits (a byte) 256, 16 bits 65,536.
- A floating-point number is a sign, an exponent (range) and a fraction (precision). Floats are packed tightly near zero.
- BF16 is the standard for training and releases; FP8 is common for big models; FP4 works only with shared scales.
- Block formats give a group of weights one shared scale: MXFP4 is 4.25 bits per weight, Q4_0 4.5, Q8_0 8.5.
- Fewer bits: smaller files, less memory read per token, faster sums. Size = parameters × bits ÷ 8.
Words to know
- Bit
- The smallest unit of computer memory: a 0 or a 1.
- Byte
- 8 bits. File and memory sizes are counted in bytes.
- Floating point
- A way to store numbers as a sign, an exponent and a fraction, like scientific notation in binary.
- Exponent
- The part of a float that sets its size, and so the format’s range.
- Fraction (mantissa)
- The part of a float that holds its digits, and so its precision.
- BF16
- A 16-bit float with the range of FP32 and less precision. The standard for model weights.
- FP8
- An 8-bit float. Used to train and release some of the largest models.
- MXFP4
- A block format: 32 four-bit floats sharing one scale, 4.25 bits per weight.
- Mixed precision
- Doing most of the work in few bits and the sensitive parts in more.
- Overflow
- A number too big for its format, which turns into infinity and breaks the calculation.
Go to the source
This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.
-
Mixed Precision Training
How to train in 16 bits without losing accuracy, and the “loss scaling” trick FP16 needed.
-
A Study of BFLOAT16 for Deep Learning Training
Why the brain float’s wide range makes training simpler.
-
FP8 Formats for Deep Learning
Where the E4M3 and E5M2 8-bit formats were defined. Short and concrete.
-
Microscaling Data Formats for Deep Learning
The block formats with shared scales, including MXFP4.
-
DeepSeek-V3 Technical Report
Section 3.3 describes training a 671-billion-parameter model mostly in FP8.
Check yourself
5 questions. Tap the answer you think is right.
0 of 5 answered
Lesson complete
Answer every question above to complete this lesson.
Your progress is saved on this device only.
Next lessonMachine learning: letting data choose the numbers