Zachary Montague

Lab

KV cache and batching

Every active request keeps a key and a value for every token, in every layer. Add users or context and the cache fills. When it is full, new requests wait.

Illustrative model, not measurements.

GPU 0 KV cache 17.2 of 60.0 GB
GPU 1 KV cache 17.2 of 60.0 GB
  • weights, half per GPU
  • runtime reserve
  • KV cache
  • free
  • kept free (10%)
Batch
64 running, 0 waiting
KV cache needed per GPU
17.2 GB
KV budget per GPU
60.0 GB
KV per token, per GPU
65,536 bytes
Requests that fit at this context
223

Fits. Every request runs in the batch.

Latency as users grow

One request through LLM inference