All videosOther topics0:36

KV cache, memory hierarchy, and continuous batching

The KV cache trades memory for less repeated compute; paging and continuous batching coordinate capacity, admission, and reuse across active requests.

Links containing ?t= open the video at a specific second.

Video summary

The ideas to retain

01

What the KV cache actually stores

In causal attention, once the model has processed a token, that token’s K and V projections do not need to be recomputed from scratch at every later decoding step. The runtime can retain…

02

A useful memory formula — with explicit limits

For an autoregressive full-attention transformer where each cacheable layer stores K and V in the standard layout, an estimate for one sequence is:

03

Illustrative arithmetic, not a benchmark

Assume a fictional architecture with:

Key moments

Jump directly to a section

  1. The KV cache consumes capacity per sequence
  2. Continuous batching rebuilds the batch each step
  3. Paging turns capacity into assignable pages