Speaker Notes

What Is LLM Inference? How AI Models Generate Responses

LLM inference transforms static model weights into real-time responses through continuous batching, compute-bound prefill, and memory-bound token decoding.

IBM Technology · 7:45 · YouTube ↗

Talk · solo speaker  Beginner · concepts and serving strategy

Highlights

3 clips · 3 min of 8 min
    • Processing individual requests wastes massive GPU resources and tanks throughput.
    • Continuous batching slots new requests in as soon as older ones finish to keep hardware near full utilization.
    • Prefill reads the entire prompt at once to build the KV cache, making it compute-bound.
    • Decode generates tokens one by one and relies on the KV cache, making it memory bandwidth-bound.
    • Time to first token (TTFT) measures the duration of the prefill phase.
    • Inter-token latency (ITL) measures the speed of each step in the decode phase.

Questions this video answers

9 · every answer cites the moment it was said
01 What does an inference engine do? 2 sources · 1:16

An inference engine takes static model weights and turns them into a system that can serve requests reliably and at scale. It manages GPU resources, schedules incoming requests, and decides how to process work together. Examples of inference engines include vLLM, Ollama, and Llama CPP.

02 Why do inference engines use OpenAI compatible endpoints? 2 sources · 1:45

Most inference engines expose standard OpenAI compatible endpoints so developers can use the same request format regardless of the underlying model. This makes it easy to swap one model for another in an application without rewriting any code.

03 How does tokenization impact prompt costs? 2 sources · 2:15

Tokenization breaks text into tokens and maps each one to an arbitrary token ID that the model processes. This step dictates your prompt cost because you are billed per token. While larger vocabularies represent text more efficiently with fewer tokens, they introduce computational overhead during training.

04 How does continuous batching optimize GPU usage? 2 sources · 3:49

Processing individual requests one by one wastes enormous amounts of GPU resources and tanks system throughput. Continuous batching groups requests together and immediately slots a new request in as soon as a previous one finishes. This mechanism keeps GPUs running near full utilization at all times.

05 What happens during the prefill phase? 2 sources · 4:40

During the prefill phase, the model reads the entire prompt at once to build an understanding of it and lays down a key value cache. This step requires huge bursts of parallel math, making it compute-bound and limited by raw hardware computation capacity.

06 Why is the KV cache necessary for long conversations? 2 sources · 4:40

The KV cache acts as a running memory of everything the model has read so far in the conversation. Without it, the model would have to reprocess your entire conversation over again for every single token it wants to output.

07 How does the decode phase generate tokens? 2 sources · 5:19

The decode phase generates the model's response one token at a time through repeated forward passes that produce a probability distribution over the vocabulary. Each generated token depends on the previous ones and requires referencing the entire KV cache.

08 Why is the decode phase memory bandwidth bound? 2 sources · 6:07

Unlike the prefill phase which demands raw compute, the decode step is limited by how fast data can move out of memory rather than raw math capacity. Prefill wants raw compute, while decode wants fast memory access.

09 What do TTFT and ITL measure? 2 sources · 6:25

Time to first token measures how long the prefill step takes before the user receives the first token. Inter token latency measures the time delay between individual tokens received by the user during the decode phase.

Section-by-section summary

5 parts

Inference costs and engine basics

Inference occurs every time a model generates a response, eventually costing more over time than the initial training phase. Inference engines like vLLM or Ollama manage these requests to ensure reliable and scalable serving.

Tokenization and hardware routing

Incoming requests are sent to OpenAI-compatible endpoints and translated into token IDs via tokenization, which dictates prompt costs. The inference router then directs the request to the most optimized available hardware.

Continuous batching maximizes GPU utilization

Processing single requests sequentially destroys system throughput. Modern engines use continuous batching to dynamically slot new requests in as soon as active ones complete.

Prefill and decode computational differences

Inference splits into a compute-bound prefill phase that builds a KV cache and a memory-bound decode phase that generates tokens sequentially. The KV cache prevents conversations from slowing down as context length grows.

Benchmarking latency metrics

System performance is evaluated using time to first token for prefill speed and inter-token latency for decode speed. Together, these metrics define the real-time responsiveness experienced by users.

0:00 / 7:45
k play/pause · f fullscreen · m mute
n next · p previous clip · t highlights/full
< > slower/faster · / search what was said
  • Inference engine2× · first 1:16

    Software that manages a pile of weights to serve requests reliably and at scale.

  • Tokenization1× · first 2:15

    The process of breaking text into tokens and mapping each to an arbitrary token ID.

  • Continuous batching1× · first 4:00

    A scheduling technique where completed requests are immediately replaced by new ones to keep GPUs utilized.

  • Prefill phase4× · first 4:25

    The compute-bound phase where the model reads the entire prompt at once and builds the KV cache.

  • KV cache3× · first 4:40

    A running memory of everything the model has read so far in the conversation.

  • Decode phase4× · first 4:25

    The memory bandwidth-bound phase where the model generates response tokens one at a time.

  • Time to first token1× · first 6:25

    The latency metric showing how long the prefill step takes to deliver the first token.

  • Inter token latency1× · first 6:35

    The latency metric measuring the time interval between tokens during the decode phase.