Shipping ItLesson 50 of 74

Module 6 · Shipping a model, not just a web app

Where inference time actually goes

In this lesson

  • 10 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 2 of 9 in this chapter

This chapter’s goalPut a model behind an HTTP endpoint with a measured latency budget and a stated cost per request, ship a new version by shadow then canary rather than by hope, and detect the week its inputs stop resembling the data it was trained on.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
Two clocks inside one language-model requestPrefill: the whole prompt at onceCompute-bound and parallelA 2,000-token prompt is not twenty times a100-token oneSets time to first tokenShortening the prompt helps hereDecode: one token at a timeMemory-bandwidth-bound: a full pass over theweights per tokenFewer bytes to read means faster: 4-bitroughly doubles the rateSets tokens per secondOutput length is the lever that matters mostPrefill sets the time to first token. Decode sets tokens per second, and because it is limited byreading the weights rather than by arithmetic, a smaller or quantised model is faster for a purelymechanical reason.
Prefill sets the time to first token. Decode sets tokens per second, and because it is limited by reading the weights rather than by arithmetic, a smaller or quantised model is faster for a purely mechanical reason.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

Two very different clocks

For a small model (a tree, a logistic regression, an embedding) inference is arithmetic on a fixed-size input, and it takes the same time every request. Measure it once and you know it.

For a language model, generation is a loop, and the cost is in two distinct phases that behave differently:

  • Prefill. The whole prompt is processed at once. This phase is compute-bound and parallel, so a 2,000-token prompt is not twenty times slower than a 100-token one, but it does set your time to first token.
  • Decode. Tokens come out one at a time, each requiring a full pass over the weights. This phase is memory-bandwidth-bound: the limit is how fast the weights can be read from memory, not how fast the chip can multiply.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Agents and Automation exam.

Stuck on something?Ask Tri, your AI tutor

How to cite: Addaly (2026) ‘Where inference time actually goes’, in Shipping It. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/cloud-and-shipping/where-inference-time-goes (Accessed: 29 November 2026).