Skip to content
StackDecode
System Design
19. AI System Design and LLM InfrastructureAnimated

LLM Inference Architecture

How an LLM serves requests.

The idea

A gateway, scheduler, GPU workers with KV cache, and streaming responses.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

PREFILL: the whole prompt is processed in parallelp1p2p3p4p5p6

Prefill reads the whole prompt at once. It is compute-bound, and sets time-to-first-token.

generated:
0
1/7

Prefill and decode have different bottlenecks, which is why serving systems treat them differently.

Step by step

  1. 1Request enters the gateway
  2. 2Scheduler batches it
  3. 3Prefill processes the prompt
  4. 4Decode streams tokens

Where it is used

Chatbots and APIs.

Watch out for

Time-to-first-token and tokens-per-second pull in different directions.

Related