AlgoViz

Batching, decoding and serving caches

hard 7 min

Serving combines admission control, prefill, autoregressive decoding and memory management.

Trace the example

Follow the evidence through each stage, then test a change in the case.

A second request arrives while the first is decoding

A second request arrives while the first is decoding. Selected component: Two sequences inside Request queue.
Open full-size diagram

Request queue

A needs 3 steps · B needs 1

The scheduler can admit and retire requests at different times. Prefill builds a prefix cache while decode extends each active sequence.

Would increasing batch size guarantee lower latency for every user?