Log inStart free
LESSON 30.04 · 6 STAGES · 2 CONTROLS · 2 CHECKSPRO · PREVIEW

Weight-only quantization

Store the weights in 4 bits and watch a decode step read fewer bytes.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 2 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 30.04 · QUANT BAYFP16 · 64 WEIGHTS · 128 B
01
Stage 1 of 6 · FP16 weights
The layer holds 64 FP16 weights of 2 bytes each. Each decode step reads all 128 B from HBM.
Explain it simply

Each square is one weight of a small layer. Each weight takes 2 bytes. To write one token, the GPU reads every weight from its main memory. The teal cells on top are the input for this token.

An 8 by 8 grid of FP16 weights, 128 bytes in HBM. A row of 8 activations sits on top.

Weights are random, not trained.
activations x (FP16)weights, codes, scales, weight readoutput ŷ, compute timeerror
weights W in HBM · FP16, 2 bytes eachHBM read per step: 128 B64 weights × 2 B0.16−0.480.510.110.65−0.33−0.29−0.580.67−0.260.430.58−1.090.561.080.480.34−0.210.150.00−0.060.300.28−1.01−0.660.23−1.56−0.760.650.000.741.330.19−0.040.01−0.380.000.630.020.000.590.11−0.680.090.870.620.06−0.880.08−0.670.290.540.250.21−0.220.170.54−0.170.130.460.010.47−0.14−0.141.09−0.020.210.34−1.090.120.290.68xr1r2r3r4r5r6r7r8weights W in HBM · FP16, 2 bytes eachHBM read per step: 128 B64 weights × 2 B0.16−0.480.510.110.65−0.33−0.29−0.580.67−0.260.430.58−1.090.561.080.480.34−0.210.150.00−0.060.300.28−1.01−0.660.23−1.56−0.760.650.000.741.330.19−0.040.01−0.380.000.630.020.000.590.11−0.680.090.870.620.06−0.880.08−0.670.290.540.250.21−0.220.170.54−0.170.130.460.010.47−0.14−0.141.09−0.020.210.34−1.090.120.290.68xr1r2r3r4r5r6r7r8
Toy: one 8 × 8 layer; speed for an 8B model (Llama 3 8B shape) on an H100
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
bytes=nW⋅b8\text{bytes} = \sy{w}{param}{n_W} \cdot \frac{b}{8}
64⋅168=128 B64 \cdot \frac{16}{8} = 128\,\text{B}

The bytes are the weight count times the bits per weight over 8.

Common mix-ups

MYTHWeight-only quantization makes the matrix math cheaper.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
2 CHECKS · PRO
Q01With 8-bit codes instead of 4-bit codes, does the output error grow or shrink?

Make your guess, then test it in the diagram. All 2 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 2 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.