LESSON 29.17 · 6 STAGES · 2 CONTROLS · 2 CHECKSPRO · PREVIEW
Preemption: swap vs recompute
Watch a full KV pool force one request out, then bring it back two ways.
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/moEXPLAINER · 29.17 · KV POOLSTEP 3 · 32 OF 32 BLOCKS USED
01
Stage 1 of 6 · KV fills up
Each running request holds KV blocks. At step 3, requests 1, 2 and 4 hold all 32 blocks.
Explain it simply
Each row is one request, and time runs to the right. The grid on the right is the GPU's KV memory, cut into 32 blocks of 128 tokens. A long prompt fills many blocks, and every new token can need one more. Two long batch prompts take most of the grid.
Swimlanes for 13 requests up to step 3. The KV grid has 32 blocks: request 1 holds 16, request 2 holds 13, request 4 holds 3. No block is free.
request, prefill, KV blockoutput tokenslink, copieswait, work done again
Toy: 13 requests, a 32-block KV pool, 0.5 MB of KV per token (a 7B model with 32 KV heads, fp16), 1 step = 50 ms
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
A request holds blocks for its prompt and the tokens it wrote.
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.