1GB = 1e92w16 = 13e9 * 2 / GB3kv = 2 * 40 * 5120 * 24req = kv * 2048 / GB5w4 = 13e9 * 0.5 / GBweights26 GB#0#1#2#3#4#5> haiku: the seaGreywavesfold
Rose slab: the GPU · teal block: the weights, as tall as their size in memorySlate blocks: the KV cache, 4 tokens per block here · A and B are two requestsEnvelopes: requests · gold tiles: keys and values · pink tiles: answer wordsAt the back, the memory maths and the GPU: the model's weights (26 GB of a 40 GB GPU) and the KV cache, six blocks of memory. A request goes from your app to the inference server and into the model. Prefill fills the cache with the prompt's keys and values; each decode step adds one token; a second request shares the same steps, and its blocks go wherever there is room. Quantization shrinks the weights to 6.5 GB; the answer streams back to the app word by word. The prompt and the generated words are illustrations, not the output of a real model.

Serving one request

  1. Running a model in production means serving it. An inference server waits for requests. Your app sends a prompt over HTTP, "Write a haiku about the sea", and the server queues it until the GPU, the chip that runs the model, is free.

Memory and speed

Serving many users

What happens

;; step 1/10 · request
POST /v1/completions        (HTTP request)
  prompt      "Write a haiku about the sea"
  max_tokens  64

the server queues it until the GPU can take it

The numbers are the worked example from the vLLM paper: a 13-billion-weight model (OPT-13B) on one NVIDIA A100 with 40 GB. The paper writes the KV cache as 800 KB per token and 1.6 GB per request, counting in binary units (1 KB = 1,024 bytes); here 1 GB = 10^9 bytes. The cache blocks in the figure hold 4 tokens so they stay readable; vLLM uses 16 tokens per block by default. Real KV caches also live in every layer at once, not in one row.