Inference Optimization Techniques
Inference efficiency matters because a model's usability depends heavily on its inference cost and latency.
Why Speed and Cost Decide Usefulness
Imagine two AI assistants built on the same underlying model. The first pauses noticeably before it answers, and then each word arrives slowly. The second starts answering almost immediately and keeps going at a steady pace. Even if both give identical content, most people would find the second one more pleasant to work with. The difference comes from how efficiently the model's inference runs, and that difference shapes which applications can reasonably be built on top of the model.
Once a model exists, it is used to produce outputs. That use is called inference. Inference optimization is the set of techniques that aim to make this use of a model better optimized. A model's usability depends heavily on its inference cost and latency. Cheaper inference makes AI-powered decisions more affordable, and faster inference makes it possible to put AI into a wider range of applications. Because so much value depends on these two properties, it is worth learning how they are measured before trying to improve them. You cannot tell whether an optimization helped unless you know what you were measuring in the first place.
Keep one question in mind as you read: if several different techniques can each optimize inference, how do they relate to one another? This overview answers that question at the level of names and roles. The detailed mechanics are covered in later chapters.
Three Efficiency Metrics
The common efficiency metrics fall into three families: latency, throughput, and utilization. Each one answers a different question about the same running system. Latency asks how long a single request takes to get a response. Throughput asks how much work the model can process over a period of time. Utilization asks how much of the available hardware capacity is being put to use. Keeping these questions separate is the first step, because a system can look excellent on one measure and poor on another.
| Metric | Question it answers | What it tracks |
|---|---|---|
| Latency | How long does one request take to get a response? | The time for a single request |
| Throughput | How much work can the model process over a period of time? | Total work completed over time |
| Utilization | How much of the available hardware capacity is being used? | The share of hardware capacity put to use |
The three efficiency metrics, each describing a different aspect of a running system
Splitting Latency into TTFT and TPOT
For language model-based inference, the source recommends looking inside latency rather than treating it as one number. Latency can be broken into two parts. The first is time to first token, abbreviated TTFT, which is influenced by the prefilling phase. The second is time per output token, abbreviated TPOT, which is influenced by the decoding phase. Put simply, one clock measures how long you wait before anything appears, and the other measures how quickly the rest of the output follows.
What do you think happens?
A response's first token takes a long time to appear, but after that the words stream out quickly. Which latency measure is large, TTFT or TPOT?
Reveal answer
TTFT is large, and TPOT is small
TTFT measures the wait before the first token and is influenced by prefilling. TPOT measures the pace of each later token and is influenced by decoding. This pattern is a long initial wait followed by a quick pace.
The Latency and Throughput Trade-off
Throughput is the lens through which cost is most directly seen. The source states that throughput metrics are directly related to cost. The more inputs a system can process in a given period, the more work each unit of hardware and time is doing. When throughput is low, the same hardware must stay busy for longer to handle the same workload, and that expense accumulates.
The more important lesson is the trade-off the source names between latency and throughput. You can potentially reduce cost if you are willing to accept increased latency, and reducing latency often involves increasing cost. The two metrics pull against each other. A system tuned to answer each request as quickly as possible often gives up some of its ability to handle many requests at once. A system tuned to handle a large volume of work may make each individual request wait longer. Neither end of this trade-off is automatically correct. The right balance depends on what the application needs.
Consider two services built on the same model. A live tutoring app needs replies to start quickly, so its designers may accept higher cost to keep latency low. A nightly batch service that summarizes documents has no user waiting on each result, so its designers may accept longer per-request waits in exchange for handling a large volume of work at lower cost. The model is the same in both cases; the balance point is different because the applications differ.
Model-Level and Service-Level Optimization
Once you can measure efficiency, the next question is how to improve it. The source describes inference optimization techniques that operate at two levels: the model level and the inference service level. The distinction is less about speed and more about what is allowed to change. Model-level optimization often requires changing the model itself, and the source warns that this can lead to changes in model behaviors. Inference service-level optimization, by contrast, typically keeps the model intact and changes only how the model is served.
| Aspect | Model-level optimization | Inference service-level optimization |
|---|---|---|
| What changes | The model itself | How the model is served |
| Model intact? | Not necessarily; it may be altered | Typically kept intact |
| Main risk the source names | Changes in model behaviors | Not identified as a risk in the source |
Model-level and service-level optimization compared
The source also points out a practical reality. Given the availability of model APIs, most application developers will use those APIs with their built-in optimization instead of implementing these techniques themselves. The techniques may not be relevant to every application developer, but understanding what is possible helps you evaluate the efficiency of a model API you are considering. When a provider quotes a fast or cheap service, knowing which level of optimization might be behind that claim gives you better questions to ask.
What Makes a Technique an Inference Optimization
An inference optimization technique is a technique used to optimize inference, meaning the use of a trained model to produce outputs. The source names three of them in this overview: quantization, distillation, and parallelism. The word including in the source signals that the list is not presented as complete.
The Three Techniques at a Glance
Each technique is introduced here only by name and role. Quantization, distillation, and parallelism are discussed in detail in Chapters 7 through 9. Treat this section as a map. It tells you what each technique is called, and the later chapters supply the mechanics.
- Quantization: one of the named inference optimization techniques, covered in the course's Chapters 7 through 9
- Distillation: one of the named inference optimization techniques, covered in the course's Chapters 7 through 9
- Parallelism: one of the named inference optimization techniques, covered in the course's Chapters 7 through 9
Where This Overview Fits in the Course
This overview introduces the inference optimization material in the module. The source says the three techniques are discussed in Chapters 7 through 9, so the detailed mechanics of quantization, distillation, and parallelism are found in those chapters rather than in this overview.
Application development is the topic that follows the inference optimization material. The source presents the two in sequence, with its heading appearing directly after the optimization material. The order is the lesson to carry forward: the optimization techniques come first, and application development comes next. The source does not describe how application development depends on these techniques, so do not assume a specific link beyond that order.
Common Mistakes With Efficiency Terms
Common mistake Treating latency as a single number
What it looks likeReporting one average response time and calling the system fast.
Why it failsLatency for language model inference splits into TTFT and TPOT, which are influenced by different phases. One figure hides which part is slow.
Do this insteadReport TTFT and TPOT separately, and name the phase that influences each.
Common mistake Assuming high throughput means low latency
What it looks likeConcluding that a system handling many requests must answer each one quickly.
Why it failsThe source names a trade-off between latency and throughput. Optimizing for handling large volume can make each request wait longer.
Do this insteadEvaluate latency and throughput together and decide which one the application needs most.
Common mistake Assuming lower latency is always better
What it looks likeChoosing the fastest configuration without checking its cost.
Why it failsThe source states that reducing latency often involves increasing cost. Neither end of the trade-off is automatically correct.
Do this insteadBalance latency against cost according to what the application needs.
Common mistake Assuming every optimization changes the model
What it looks likeBelieving that a faster service must mean a different model underneath.
Why it failsThe source contrasts model-level optimization, which may change the model, with service-level optimization, which typically keeps the model intact.
Do this insteadAsk which level an optimization acts on before judging its effect on behavior.
Practice: Choosing What to Watch
Choose a hypothetical AI assistant for a live chat app where users expect replies to start immediately. Explain which latency clock you would watch most closely, which phase influences it, and what trade-off you might accept against cost. Then explain why a single average latency figure would be insufficient for judging the assistant.
Hints
- Start by deciding which clock covers the wait before anything appears.
- Recall which phase the source ties to that clock.
- Think about what the trade-off between latency and cost means for a live chat setting.
Key Takeaways
- A model's usability depends heavily on its inference cost and latency, so these must be measured before they can be improved.
- The three common efficiency metrics are latency (time for one request), throughput (work processed over time), and utilization (how much hardware capacity is used).
- Language model latency splits into TTFT, influenced by prefilling, and TPOT, influenced by decoding. Lower latency often raises cost, and throughput is directly tied to cost.
- Inference optimization techniques act at the model level, which may change model behaviors, or at the inference service level, which typically keeps the model intact.
- The overview names quantization, distillation, and parallelism, which the course covers in Chapters 7 through 9, and application development follows this material.