L1 Beginner · Module 0: Orientation
0.1What inference engineering is
Training makes a model once. Inference runs it billions of times. Inference engineering is the craft of making each of those runs fast, cheap and reliable, and this chapter maps the territory.
By the end you will be able to
- ✓Say what inference engineering is and how it differs from training
- ✓Name the numbers inference engineers are judged on (TTFT, TPOT, throughput, cost)
- ✓Place any optimization on the six-layer inference stack
- ✓Do a "speed of light" estimate for decoding a 7B model
A trained language model is a file of numbers. Inference is running that file to turn a prompt into tokens. Inference engineering is everything between “the model works in a notebook” and “ten thousand people are using it at once, each gets an answer in under a second, and the GPU bill is affordable.”
Training once, inference forever
Training is a single huge job. It runs for weeks, you optimize it once, and then it’s over. Inference has a different shape:
| Training | Inference | |
|---|---|---|
| How often | Once per model | On every request, forever |
| Unit of work | A big batch of fixed-length sequences | Many small requests of unpredictable length, arriving at random times |
| What matters | Total time to finish | Latency per user and throughput per GPU |
| Bottleneck | Usually compute | Usually memory bandwidth (during decode) |
| Failure mode | The run takes longer | Users wait, requests time out, money burns |
Once a model is popular, the total compute spent serving it can exceed what was spent training it. That is why companies hire people whose whole job is making inference efficient.
The numbers you are judged on
Every decision in this curriculum moves one of these:
- TTFT (time to first token): how long the user stares at a blank screen. It is set by the prefill phase, which processes the whole prompt.
- TPOT / ITL (time per output token, inter-token latency): how fast text streams once it starts. It is set by the decode phase, which produces one token per step.
- Throughput: total tokens per second across all users on a GPU. More throughput means fewer GPUs.
- Cost: dollars per million tokens. Roughly, GPU price per hour divided by throughput.
- Goodput: throughput that also meets the latency targets (SLOs). This is what actually counts in production.
Why it’s hard: one token at a time
LLMs are autoregressive: token depends on token , so the output is produced one step at a time. Each decode step runs the entire model to produce one token per sequence.
Here is what that means for Mistral 7B in FP16 on an H100:
Every decode step must stream all 14.5 GB of weights from memory into the chip, so even with infinitely fast math:
That is the speed of light for this model on this GPU. Meanwhile the H100’s ~989 TFLOP/s of tensor-core compute sits about 99.7% idle. Almost every trick in this curriculum comes from looking at that gap:
- Batching: one weight read serves 64 users instead of 1 (Modules 3 and 10).
- Quantization: INT4 weights are 4× fewer bytes to stream (Module 12).
- Speculative decoding: verify several guessed tokens per weight read (Module 11).
- KV-cache engineering: the other thing decode has to read every step (Module 9).
The inference stack
Inference problems live at different layers, from the silicon up to the business. A good inference engineer can move between them. A slow endpoint might be a routing problem, a batching problem, a kernel problem, or simply the wrong GPU.
Inference engine
“Which requests run on this step, and where is each one’s KV cache?”
Lives here
- –vLLM
- –SGLang
- –TensorRT-LLM
- –continuous batching
- –PagedAttention
Knobs you turn
- ◆max batch size
- ◆chunked prefill
- ◆prefix caching
- ◆speculative decoding
This curriculum climbs the stack from the bottom up. You learn the hardware first, because every layer above it is shaped by the same two numbers: FLOP/s and bytes/s.
What an inference engineer actually does
A realistic week might include:
- Measuring: load-test a new model, find that p99 TTFT spikes past 2 s at 40 requests/s (Module 13).
- Diagnosing: notice long prompts block short ones, and enable chunked prefill (10.3).
- Optimizing: switch the KV cache to FP8, fit twice as many sequences, and raise throughput (9.6).
- Profiling: find a non-fused layer norm eating 6% of step time, and fuse it (7.1, 8.1).
- Scaling: put a KV-aware router in front of 8 replicas so repeat conversations hit warm caches (15.3).
- Pricing: recompute cost per million tokens and decide whether an H100 or two L4s is cheaper for this traffic (16.1).
Sources
Check your understanding
0 / 4 answered1.Which phase mostly determines time to first token (TTFT)?
2.A 14 GB model is decoded for one user on a GPU with 2 TB/s of memory bandwidth. What is the best possible step time?
3.Why does batching many users together raise throughput during decode?
4.At peak load your server produces lots of tokens per second, but only 60% of requests meet both their TTFT and TPOT targets. Which metric captures this?