LESSON 30.10 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW
KV-cache quantization
See a KV cache shrink to 8 or 4 bits, and what the rounding costs.
Needs30.09 FP8 inference
Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 30.10 · KV CACHEFP16 · 8 TOKENS · 256 B
01
Stage 1 of 6 · The KV cache
The KV cache keeps a key and a value for each of 8 tokens. Key channel 4 is an outlier channel.
Explain it simply
You see two grids of squares. Each row is one token, and each square is one number: a big square is a big number. The keys on the left have one column, channel 4, with numbers about six times larger than the rest. Real models show the same thing in their keys, but not in their values.
Two grids of 8 tokens by 8 channels: keys on the left, values on the right. Key channel 4 holds numbers near 3.7; the other numbers stay near 0.6.
keys and values (hollow: negative, also for errors)scales, bitsrounding errorattention resultexact FP16, or a 0
Toy: one attention head, 8 cached tokens × 8 channels, seeded numbers
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Every key and value number takes 2 bytes.
PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
- 5 more stages and 2 live controls
- 2 mix-up cards and 3 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.