What makes a chatbot feel instant while another one leaves users staring at a blinking cursor? The answer almost never comes down to raw GPU horsepower alone. It comes down to how well the serving stack understands where latency actually comes from. Low-latency LLM inference is the craft of getting tokens out of a large language model fast enough that a human doesn’t notice the wait, and it is equal parts systems engineering, memory management, and workload design. (Latency (engineering)))
This article breaks down the real bottlenecks, the techniques that move the needle, and the mistakes that quietly add hundreds of milliseconds to every request.
Why latency splits into two very different problems
Before optimizing anything, teams need to accept that a transformer generates text in two phases with opposite performance profiles. During prefill, the model reads the entire prompt at once. This step is compute-bound and highly parallelizable, because all the prompt tokens can be processed together. During decode, the model produces one token at a time, and each new token requires reading the model weights from memory. That makes decode memory-bandwidth-bound rather than compute-bound.
This split is the foundation of nearly every latency optimization in production today, and it is documented in detail in the vLLM paper on PagedAttention published at SOSP 2023. The practical consequence: a long prompt hurts time-to-first-token, while a slow decode rate hurts the perceived typing speed. If a team treats “latency” as one number, they will optimize the wrong phase.
The two metrics that actually matter
Production teams usually report two numbers. Time-to-first-token (TTFT) captures queueing plus prefill, so it reflects how long a user waits before anything appears. Time-per-output-token (TPOT), sometimes called inter-token latency, captures decode speed. These are the same metrics used in the MLPerf Inference benchmark suite, which added LLM workloads in its 2023 to 2024 rounds. Anyone building a latency budget should track both separately, because a system can have excellent TTFT and terrible TPOT, or the reverse.
The KV cache is where most latency budgets go to die

The key-value cache stores attention states for every token already processed so the model doesn’t recompute them. It is essential for speed, but its size grows linearly with sequence length and batch size. At long context, the KV cache can consume more GPU memory than the model weights themselves.
This creates a brutal trade-off. Larger batches improve throughput but fragment memory. Long contexts improve usefulness but crowd out concurrent requests. PagedAttention, introduced with vLLM, manages the cache in non-contiguous blocks so memory waste drops sharply. The same memory pressure is why capacity planning deserves its own discipline; a useful primer on why memory capacity matters for inference planning explains how KV cache growth, batch size, and context length interact before you ever touch a latency knob.
A practical tip that saves hours
Measure KV cache occupancy under realistic prompt lengths, not short test prompts. Teams routinely benchmark with 200-token prompts, ship, then discover that real users paste 4,000-token documents and the cache overflows. When that happens, the server starts preempting requests, and latency spikes unpredictably. Load-test with the 90th-percentile prompt length from actual traffic logs, not the average.
Continuous batching beats static batching every time
Older serving systems waited for an entire batch of requests to finish before admitting new ones. A single long generation would hold up dozens of short ones. Continuous batching, also called iteration-level scheduling, admits and retires requests on every decoding step. This idea was formalized in the Orca system presented at OSDI 2022, and it is now standard in production servers.
The effect on tail latency is dramatic. Under mixed workloads, continuous batching can cut queueing delay substantially because short requests no longer wait behind long ones. If you are deciding how requests should flow through your system, the trade-offs between batch and real-time inference are worth studying before committing to an architecture, since batch processing can be far cheaper for workloads that tolerate delay. (AI inference architecture: A practical enterprise guide)
Speculative decoding: trading spare compute for speed
Speculative decoding uses a small draft model to propose several tokens, which a larger model then verifies in parallel. Under the standard scheme, the output distribution stays identical, so quality does not change. Wall-clock time per token drops when the draft model guesses well. The original 2023 papers on speculative decoding reported roughly 2x to 3x speedups, but those figures are highly workload-specific. Code generation and predictable text tend to benefit more than open-ended creative writing, where the draft model misses more often.
The common mistake here is deploying speculative decoding without measuring the acceptance rate. If the draft model agrees with the target model less than roughly 60 to 70 percent of the time, the extra compute often cancels out the gains. Track acceptance rate per task type and disable speculation for workloads where it underperforms.
Quantization and attention kernels: shaving bytes and I/O
Because decode is bandwidth-bound, reducing the number of bytes read per token directly reduces latency. Quantization to 8-bit or 4-bit weights shrinks memory traffic, and methods such as GPTQ and AWQ were developed specifically to limit quality loss. Results are not uniform across tasks, so validate on your own evaluation set rather than trusting a leaderboard.
Attention itself also benefits from better memory handling. FlashAttention, introduced by Dao and colleagues in 2022, tiles the attention computation to keep data in on-chip SRAM, reducing memory reads and writes without changing the underlying math. It speeds up both training and inference, and it is now widely integrated into serving stacks.
| Technique | Primary bottleneck addressed | Typical effect | Main risk |
|---|---|---|---|
| Continuous batching | Queueing latency | Lower tail latency under mixed load | Scheduler tuning complexity |
| Paged KV cache | Memory fragmentation | Higher concurrency at long context | Implementation maturity |
| Speculative decoding | Decode speed | Workload-dependent per-token gains | Low acceptance rate wastes compute |
| Quantization | Memory bandwidth | Fewer bytes read per token | Task-specific quality loss |
| FlashAttention | Attention memory I/O | Faster attention at long sequences | Kernel and hardware compatibility |
The serving framework is the layer most teams underestimate
In practice, most teams do not build a scheduler from scratch. They adopt a serving framework and tune it. vLLM, TensorRT-LLM, and Text Generation Inference are the commonly cited options, and each implements paged KV caches, continuous batching, and quantization to varying degrees. The vLLM documentation is a solid practical reference for which features exist in which version.
Two warnings apply. First, feature parity and performance differ by version and hardware, so a benchmark from six months ago may not describe your deployment. Second, vendor benchmarks often use favorable settings, so treat any single speedup number as a hypothesis to test, not a fact to cite in a planning document.
What actually works in practice
- Pin your framework version and record it alongside every latency measurement.
- Benchmark with your own model, your own prompt distribution, and your own hardware.
- Watch for the difference between p99 and median latency; users remember the slow requests.
- Instrument TTFT and TPOT separately in production, not just in load tests.
A structured approach to measuring inference latency end to end helps here, because it forces teams to separate network time, queueing time, prefill, and decode instead of blaming the model for everything.
Architecture choices that quietly set your latency floor
No amount of kernel tuning rescues a poorly chosen architecture. Model size, context window, and deployment topology all set a floor that optimization cannot break through. A model that needs four GPUs to hold its weights will always carry inter-GPU communication overhead. A system that routes every request through three microservices adds network hops that no batching strategy can remove.
This is why a clear picture of AI inference architecture matters before tuning begins. Decisions about where the model lives, how requests are routed, and whether caching sits in front of the model determine the achievable latency range. Teams that tune first and architect second usually end up rebuilding.
Caching is the cheapest latency win
A surprising share of production traffic is repetitive: the same system prompt, the same FAQ, the same follow-up phrasing. Prompt caching and response caching can eliminate entire inference calls. Exact-match response caching is trivial to implement and safe for deterministic tasks. Prefix caching, which reuses the KV cache for a shared system prompt, is built into several modern serving stacks and can cut TTFT noticeably for long instructions. Neither technique is glamorous, but both reduce load on the model, which indirectly improves latency for everything else.
Common mistakes that add hidden milliseconds
Even well-funded teams stumble on the same handful of issues. Streaming responses but buffering them in a proxy defeats the purpose of streaming, because the user still waits for a full chunk. Setting aggressive timeouts that trigger retries under load can double the effective request rate and make latency worse. Logging full prompts synchronously inside the request path adds disk I/O to every call. And measuring latency from a warm cache, on an idle machine, with a single concurrent user produces numbers that collapse under real traffic.
Another frequent error is ignoring tokenizer overhead. For short prompts, tokenization and detokenization can be a measurable fraction of total time, especially in high-throughput services. Profile the whole request path, not just the model forward pass.
Conclusion
Low-latency LLM inference is not a single switch. It is a stack of decisions: separating prefill from decode, managing the KV cache honestly, batching continuously, choosing quantization and attention kernels that fit the hardware, and picking a serving framework you can actually measure. The teams that get this right share one habit. They instrument first, optimize second, and never trust a speedup number they have not reproduced on their own workload. Latency is a property of the whole system, and the fastest systems are usually the ones that were measured the most carefully.
What is the difference between TTFT and TPOT?
Time-to-first-token measures how long a user waits before the first token appears, covering queueing plus prefill. Time-per-output-token measures the speed of subsequent decoding. A system can be fast at one and slow at the other, so both should be tracked separately when setting latency targets.
Why is decode slower than prefill for large language models?
Prefill processes all prompt tokens in parallel, so it is compute-bound and efficient. Decode generates one token at a time, and each token requires reading the model weights from memory. That makes decode memory-bandwidth-bound, which is why reducing bytes read per token through quantization helps so much.
Does speculative decoding change the quality of output?
Under the standard speculative decoding scheme, no. The larger model verifies every proposed token, so the output distribution stays the same as normal decoding. The gains come from speed, not from approximating the model. However, if the draft model’s acceptance rate is low, the extra compute can cancel out the benefit.
How much does continuous batching improve latency?
It depends on the workload mix. Continuous batching mainly reduces queueing delay and tail latency, especially when short and long requests arrive together. In workloads where every request is the same length, the improvement is smaller. Measure p99 latency under realistic traffic rather than relying on a general figure.
Is quantization always worth it for latency?
Not always. Quantization reduces memory traffic, which helps most in the bandwidth-bound decode phase. But quality loss varies by method, model, and task, and some tasks degrade more than others. Validate on your own evaluation set, and consider keeping higher precision for quality-sensitive endpoints.
What is the most common cause of unexpected inference latency?
Unrealistic benchmarking. Teams test with short prompts, a single user, and a warm cache, then ship to traffic with long prompts and high concurrency. The KV cache fills, requests get preempted, and latency spikes. Load-testing with the 90th-percentile prompt length from real logs catches most of these surprises early.







