Log inStart free
LESSON 29.05 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Paged attention and block tables

Watch six requests share GPU memory through small blocks and block tables.


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/mo
EXPLAINER · 29.05 · KV BAYSTEP 4 · 113 TOKENS · 6 REQUESTS
01
Stage 1 of 6 · KV grows
Each request needs KV cache memory. The memory grows by one token per step.
Explain it simply

Each row is one request, and each small box is one token. The model keeps the keys and values of every token, so a row grows by one box at each step. By step 4 the six requests hold 113 tokens.

Six rows of token boxes, one row per request. At step 4 they hold 113 tokens.

cached tokensempty slot in a block or a booked rangefree slotwaste: empty or never usedtime cursor
R1R2R3R4R5R602468101214step 4each request's tokensGPU memory · 128 slotsR1: 20 tokens = 16 prompt + 4 answerall requests at step 4: 113 tokensR1R2R3R4R5R602468101214step 4each request's tokensGPU memory · 128 slotsR1: 20 tokens = 16 prompt + 4 answerall requests at step 4: 113 tokens
Toy: 29.C1's 6 requests, a 10-token system prompt, 128 slots
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
n=p+g\sy{n}{data}{n} = \sy{p}{data}{p} + \sy{g}{data}{g}
n=16+4=20n = 16 + 4 = 20

A request holds its prompt tokens plus its answer so far.

Common mix-ups

MYTHPaging makes attention compute faster.

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

Predict, then reveal
3 CHECKS · PRO
Q01With blocks of 8 tokens, do more or fewer slots sit empty at the worst step?

Make your guess, then test it in the diagram. All 3 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 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.