Log inStart free
LESSON 29.08 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

KV-cache offloading

Watch idle chat caches leave a full GPU for CPU memory and NVMe, then return.


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

Go Pro · $8.25/mo
EXPLAINER · 29.08 · KV BAYSTEP 5 · GPU 32/32 · R2 IDLE
01
Stage 1 of 6 · Idle caches
R2 has its answer, and its 5 blocks stay on the GPU for the follow-up. The GPU is full.
Explain it simply

Each chat sends a follow-up 8 steps after its answer. The server keeps a finished chat's cache, its keys and values, on the GPU so the follow-up can reuse it. R2's blocks turn to outlines: idle. Now 32 of the 32 blocks are taken.

Step 5. The GPU grid has 32 of 32 blocks taken. R2's 5 blocks are idle.

KV blocks: filled running, outlined idlefree blockthrown away or computed again; dashed: waitingtime cursor, link speedtime to bring a cache back
step02468101214161820222426PCIe25 GB/s7 GB/sHBM 3.35 TB/sGPU32 of 32 usedCPU memory0 of 8 usedNVMe drive0 of 12 usedThrown away0 blocksR1R1R1R1R2R2R2R2R3R3R3R3R3R4R4R4R4R1R5R5R5R5R5R4R3R6R6R6R6R2R1R5R1R2R3R4R5R6idle cachesstep 5R2: ⌈17 / 4⌉ = 5 blocks · GPU 32 of 32 usedstep02468101214161820222426PCIe25 GB/s7 GB/sHBM 3.35 TB/sGPU32 of 32 usedCPU memory0 of 8 usedNVMe drive0 of 12 usedThrown away0 blocksR1R1R1R1R2R2R2R2R3R3R3R3R3R4R4R4R4R1R5R5R5R5R5R4R3R6R6R6R6R2R1R5R1R2R3R4R5R6idle cachesstep 5R2: ⌈17 / 4⌉ = 5 blocks · GPU 32 of 32 used
Toy: 29.C1's 6 chats with one follow-up each; 32 GPU blocks; an 8B model
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
b=⌈n/4⌉\sy{b}{data}{b} = \left\lceil \sy{n}{data}{n} / 4 \right\rceil
b=⌈17/4⌉=5b = \lceil 17 / 4 \rceil = 5

A cache of n tokens takes n over 4 blocks, rounded up.

Common mix-ups

MYTHA copy from any tier beats computing the cache again.

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

Predict, then reveal
3 CHECKS · PRO
Q01If the server drops idle caches, how many history tokens do the follow-ups compute again?

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 3 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.