Fast and Capable: Technical Paths to High-Speed LLM Inference
This article explains why speed defines the interactive experience of large language models, breaking down the two key metrics—time to first token (TTFT) and output rate—and the traditional trade-off between model size and inference speed. It then walks through mainstream acceleration techniques, including continuous batching, KV cache management, speculative decoding, quantization, parallelism with hardware interconnects, and streaming output, along with sample code for measuring streaming performance. Finally, it outlines practical engineering strategies—tiered routing, scenario-specific speed targets, and a comprehensive metrics system—for achieving both speed and capability in production LLM systems.
1. Why Speed Defines the Interactive Experience
Humans are far more sensitive to latency than most people intuitively assume. A single blink takes about 0.3 seconds; if an interface shows no feedback within that window, users perceive an obvious stall. For large language models, the experience is shaped primarily by two metrics. The first is time to first token (TTFT)—the time from when a user sends a request to when the first character appears. The second is output rate, typically measured in tokens per second, which determines how long the full response takes to finish.
These two metrics affect the experience differently. TTFT determines “how fast it starts,” while output rate determines “how fast it finishes.” In conversational scenarios, TTFT matters more. In long-output scenarios such as code generation or page generation, output rate directly determines total waiting time.
2. The Traditional Tension Between Speed and Capability
The industry has long held a rule of thumb: bigger models are slower, smaller models are faster. This judgment has a physical basis.
LLM text generation typically consists of two phases: prefill and decoding. During decoding, generating each token requires reading large amounts of model weights and historical cache. The computation per step is modest, but memory access is extremely frequent, so this phase is often bottlenecked by memory bandwidth. The larger the parameter count, the more data must be moved at each step, and the longer each step takes.
In the past, common acceleration approaches were model distillation or simply switching to a smaller model. These do improve speed, but capability degrades accordingly. To preserve the reasoning power of a large model while achieving the responsiveness of a small one, you need to work at the inference-system level. Adjusting model size is only one of several levers.
3. General-Purpose Acceleration Techniques
3.1 Continuous Batching
On the server side, multiple requests can be merged into a single batch for computation. Traditional static batching must wait for the entire batch to finish before releasing resources; continuous batching lets completed requests exit immediately while new requests join on the fly. This improves GPU utilization and reduces queuing time. Note that batching primarily improves overall throughput; its effect on the speed of any single request is limited. The two types of metrics should be evaluated separately.
3.2 KV Cache Management
During decoding, the model must store the Key and Value vectors of every layer—the KV cache. Long contexts consume large amounts of GPU memory, and when memory runs short, concurrency must be reduced. Paged cache management allocates memory blocks on demand, reducing fragmentation and allowing a single GPU to host more concurrent sessions.
3.3 Speculative Decoding
Speculative decoding uses a smaller draft model to quickly generate several candidate tokens, which the large model then verifies in parallel in one pass. If most candidates are accepted, each forward pass of the large model confirms multiple tokens, reducing the total number of decoding steps. In theory, the output distribution of this method matches direct sampling, so it does not trade capability for speed. Its benefit depends on how well the draft model matches the target model: the lower the acceptance rate, the weaker the speedup.
3.4 Quantization
Quantization converts weights and activations from high precision (such as 16-bit floating point) to lower precision (such as 8-bit integer or 8-bit floating point), reducing memory footprint and data movement. Quantization usually delivers noticeable speedups, but any accuracy loss must be confirmed through evaluation. For reasoning and coding tasks, compare performance before and after quantization on the target datasets separately—do not rely on overall averages alone.
3.5 Parallelism and Hardware Interconnects
Large models can split the computation of a single layer across multiple GPUs via tensor parallelism, or assign different layers to different devices via pipeline parallelism. These schemes reduce per-GPU compute pressure, but inter-GPU communication introduces additional overhead. Interconnect bandwidth and topology directly affect the final result.
3.6 Streaming Output
Streaming output pushes each token to the client as soon as it is generated, and the client renders it immediately. It does not change the model’s actual computation speed, but it significantly improves perceived responsiveness. In the vast majority of interactive scenarios, streaming output is a baseline requirement.
Below is sample code for measuring streaming API metrics. Teams can use it to collect data in their own environments:
import timedef measure_stream(chunks):"""chunks is an iterator of text chunks returned by the streaming API.Measures time to first token and average output rate."""start = time.perf_counter()first_at = Nonetoken_count = 0for chunk in chunks:if first_at is None:first_at = time.perf_counter()token_count += 1 # For formal measurement, count using the model's tokenizerend = time.perf_counter()if first_at is None:raise RuntimeError("No output received")ttft = first_at - startrate = token_count / max(end - first_at, 1e-6)return ttft, rate
The counting method in this code is fairly rough. For formal evaluation, count tokens using the tokenizer that matches the model, and take percentiles over multiple samples to avoid misjudgment caused by single-run fluctuations.
4. Engineering Strategies for Achieving Both Speed and Capability
Even after stacking multiple acceleration techniques, architectural trade-offs remain at the system level. The following three strategies are common in practice.
4.1 Tiered Routing
Different tasks have different requirements for capability and speed. Simple Q&A, format conversion, and short-text polishing can be handled by lightweight models or a fast path. Complex reasoning and multi-step code refactoring go to the flagship model. Routing rules can be based on task type, input length, or user-declared priority. The router itself should remain lightweight; otherwise it will offset the overall gains.
4.2 Setting Speed Targets by Scenario
Real-time interactive scenarios focus on TTFT, with the goal of starting output within a time users find acceptable. Batch-generation scenarios care more about total throughput and unit cost, so the speed requirement for individual requests can be relaxed. If both types of scenarios share the same resource pool, they tend to interfere with each other and should be scheduled separately.
4.3 Building a Comprehensive Metrics System
Looking only at the output rate of individual requests easily leads to one-sided conclusions. It is recommended to track the following metrics together: time to first token (TTFT), output rate, and overall throughput.
