LLM Inference Latency and Throughput Optimization: A Practical Guide
This article breaks down the key metrics behind large language model inference performance, including TTFT, TPOT, end-to-end latency, and throughput. It explains why text-only inference is structurally faster than multimodal inference, how compute constraints shape release schedules and model selection, and what engineering teams can do to improve speed and cost efficiency. You will find a minimal benchmarking script, a practical optimization checklist, a sample routing strategy, and common performance testing mistakes to avoid.
1. Introduction: Why Speed Has Become a First-Class Concern for LLMs
In enterprise applications, model capability matters, but response speed often determines user experience and cost per request. A slightly less capable model with a stable time to first token in the hundreds of milliseconds is often a better fit for production than a stronger model that takes several seconds to produce its first token. The core observation behind this is straightforward: text-only inference is fast, while multimodal capabilities are compute-intensive. This directly shapes how vendors schedule releases and position their product tiers.
This article sets aside specific product details and frames the observation as three general technical questions: what determines inference latency, why multimodal inference is expensive, and how engineering teams can trade limited compute for acceptable latency and throughput.
2. Latency and Throughput: Two Metrics That Must Be Measured Separately
Many performance discussions reach contradictory conclusions because they mix two different metrics:
- Time to first token (TTFT): the time from sending a request to receiving the first token. This drives the intuitive sense of whether a system feels slow.
- Time per output token (TPOT/ITL): the interval between subsequent tokens. This determines whether output feels smooth.
- End-to-end latency: TTFT plus output length multiplied by TPOT. This determines how long long-form tasks take to complete.
- Throughput (tokens/s or QPS): the total output the system produces per unit of time. This determines cost per unit and scaling requirements.
The key takeaway is that latency and throughput usually trade off against each other. Increasing batch size can significantly improve throughput and amortize the cost of reading weights, but it also lengthens queue waiting time and raises TTFT. So the question “which model is faster” is not comparable unless input length, output length, concurrency, and precision settings are fixed first.
A minimal local benchmarking skeleton is shown below (illustrative, with no dependency on any specific vendor API):
import time, statisticsdef bench(call, prompts, max_new_tokens=256, runs=5):ttft, tpot = [], []for _ in range(runs):for p in prompts:t0 = time.perf_counter()first = Nonen = 0for chunk in call(p, max_new_tokens): # streaming outputif first is None:first = time.perf_counter()n += 1t1 = time.perf_counter()ttft.append(first - t0)tpot.append((t1 - first) / max(n - 1, 1))p50 = lambda xs: statistics.median(xs)print(f"TTFT p50={p50(ttft)*1000:.1f}ms TPOT p50={p50(tpot)*1000:.1f}ms")
3. Why Text-Only Inference Is Naturally Faster
The text-only pipeline is short, and that is the structural source of its speed advantage:
- Low input encoding cost. Text goes through a single tokenizer with controllable sequence length. Images and audio, by contrast, require segmentation and encoding first, producing a large number of additional tokens.
- Attention cost grows quadratically with sequence length. Multimodal inputs often involve thousands of visual tokens, which significantly increases computation during the prefill stage and directly pushes up TTFT.
- Greater memory and bandwidth pressure. Vision encoders and projection layers add extra weights and activations, and the KV Cache grows with context length, making swapping and recomputation more likely.
- Lower batching efficiency. Multimodal requests vary widely in length, causing heavy padding waste and making efficient continuous batching difficult.
This also explains a common product pattern: vendors tend to split a high-speed text-only version and a multimodal version into different tiers, and try to release products from the same generation on the same day or within a close window. This is not a marketing cadence but a hard constraint of compute budgets and cluster scheduling windows. Training and evaluating multimodal capabilities require longer periods of exclusive resource access, so release schedules are inevitably driven by compute supply.
4. Release Cadence and Selection Logic Under Compute Constraints
From an engineering perspective, the cadence question can be broken into three layers:
- Training side: multimodal data cleaning, alignment, and evaluation pipelines take longer and occupy cluster time for extended periods.
- Inference side: before a new model goes live, capacity planning is required, reserving memory and instance counts based on peak concurrency.
- Cost side: cost per request equals instance price divided by effective throughput, and the effective throughput of multimodal inference is often only a fraction of text-only inference.
Therefore, model selection should not rely on leaderboard scores alone. Instead, build a scenario-to-metric mapping table: customer support Q&A should prioritize TTFT and stability; code completion should prioritize TPOT and context length; document and image understanding should prioritize multimodal capability, while accepting higher latency and cost and considering asynchronous processing.
5. An Actionable Optimization Checklist
Beyond the model itself, the engineering side often offers larger gains:
- Inference engine layer: enable continuous batching, paged KV Cache, operator fusion, and appropriate quantization (such as quantizing weights to lower bit widths) to trade precision within an acceptable range for memory and bandwidth savings.
- Request layer: streaming output improves perceived responsiveness; apply summary compression and retrieval-based context trimming to long inputs to control prefill length.
- Cache layer: reuse prefix caching for high-frequency prefixes; apply semantic caching for deterministic Q&A.
- Architecture layer: route text-only requests to a low-latency pool and multimodal requests to a separate high-compute pool, decoupling them with a message queue and asynchronous callbacks so that long tasks do not block short requests.
- Observability layer: use logging services and monitoring alerts to continuously collect TTFT, TPOT, queue time, and memory usage, set SLOs, and scale automatically based on them; store evaluation samples in object storage to ensure reproducible regression testing.
An illustrative routing strategy:
def route(req):if req.has_image or req.has_audio:return multimodal_pool # high compute, async, queueableif req.max_tokens <= 512:return fast_text_pool # low latency, small batchreturn general_text_pool # long text, high throughput
6. Common Pitfalls
- Comparing only end-to-end latency while ignoring differences in output length, leading to distorted conclusions.
- Measuring throughput at a single concurrency level and wrongly concluding that one approach is more cost-effective.
- Treating the precision loss from quantization as zero cost, without business-side regression evaluation.
- Sharing a resource pool between long multimodal tasks and online short requests, causing tail latency to spike.
7. Conclusion
Speed is not an attribute of a single model but a system-level property determined jointly by model capability, the inference engine, batching strategy, and resource pool partitioning. Understanding the breakdown of TTFT and TPOT, being clear about the compute cost of multimodality, and establishing evaluation baselines matched to each scenario are what allow you to make architectural choices that satisfy user experience while controlling cost under a limited compute budget.
