High-Speed LLM Inference: Technical Breakdown and Practical Guide
This article breaks down high-speed large language model inference, separating three commonly confused metrics—time to first token, output throughput, and end-to-end latency—and explains where high throughput comes from in practice: decoding characteristics, weight quantization, attention optimization, continuous batching, and speculative decoding. It also shows how to run reproducible benchmarks with a consistent methodology, how to match speed to specific use cases through tiered routing, and what supporting infrastructure and regression evaluation are needed to ship fast inference without silent quality loss.
1. Why Output Speed Has Become a Competitive Dimension
A set of high-throughput measurements for a new generation of lightweight large models has been circulating in technical communities: output speed measured in the range of hundreds to over a thousand tokens per second, with higher peaks on code generation tasks. These numbers come from community members’ own testing, not from an official vendor release. They reflect grayscale or unreleased builds, and the measurement methodology does not match standardized benchmarks, so they should be treated as a trend signal rather than a conclusion.
Setting aside whether the specific numbers are accurate, the phenomenon points to a clear technical trend: competition among lightweight models is shifting from “is the capability good enough” to “given sufficient capability, how much content can be produced per unit of time.” For developers, this means the evaluation dimensions for model selection need to expand—beyond accuracy and context length, throughput, latency stability, and cost per call belong on the same scorecard.
2. Decomposing “Fast”: Three Metrics That Must Not Be Mixed
The most common mistake when discussing speed is conflating different metrics. The rigorous approach is to define them first:
- Time to first token (TTFT): the time from sending a request to receiving the first token, which determines whether the application feels responsive. It is mainly affected by queue wait time, prompt length, model loading, and GPU memory scheduling, and is nearly independent of output length.
- Output throughput: the number of tokens generated per unit of time, which determines how long long-form output takes. It is affected by batching strategy, memory bandwidth, and the attention implementation.
- End-to-end latency: the total time the user actually perceives, approximately equal to time to first token plus the number of output tokens divided by throughput.
Mixing the three produces apparently contradictory data, such as “more than six seconds to first token, but throughput close to a thousand tokens per second.” In fact this is entirely self-consistent: queuing and the prefill stage are slow, but once decoding begins, each token is produced extremely fast. For interactive applications, high time to first token noticeably hurts the experience; for offline batch processing, throughput is what matters.
A formula makes it more intuitive:
End-to-end latency ≈ TTFT + output tokens / output throughput
For example: 2000 output tokens, 6.8 seconds to first token, and 900 tokens/s throughput gives a total of roughly 9 seconds; at only 160 tokens/s, total time exceeds 19 seconds. The same model capability, yet nearly a twofold difference in experience.
3. Where High Throughput Comes From: Reusable Engineering Techniques
Ultra-high-speed inference is not a single optimization but the result of multiple layers of techniques stacked together. The following are common industry practices:
- Computational characteristics of the decoding stage. Autoregressive decoding processes only one new token position per step, so the bottleneck is usually memory bandwidth rather than compute. Improving memory access efficiency is therefore more effective than adding compute.
- Weight quantization. Storing weights at a lower bit width reduces the data that must be moved at each step and lowers memory footprint, leaving room for larger batches.
- Attention optimization. Multi-query or grouped-query attention compresses the size of the key-value cache, and paged cache management reduces fragmentation.
- Continuous batching. Dynamically batching different requests avoids long and short requests holding each other back, significantly improving overall throughput.
- Speculative decoding. A small model or draft mechanism guesses several tokens first, then the large model verifies them in parallel; with a high hit rate, decoding speed can improve by a multiple.
- Output-side optimization. Streaming responses get the first token to the user as quickly as possible, and structured output constraints reduce wasted tokens.
One engineering caveat: throughput gains often come at the cost of memory and power, and under high concurrency the latency distribution stretches out, so tail latency must be examined rather than the mean alone.
4. How to Produce Trustworthy Measurements Yourself
Community data is hard to compare across sources because too many variables are in play. It is advisable to fix the following before testing:
- The same input length, output length, and sampling parameters;
- Whether streaming is enabled and whether the cache is reused;
- Concurrency level, warm-up rounds, and number of repetitions;
- Reporting both the mean and percentiles (such as P50, P90, P99).
A minimal usable load-testing skeleton looks like this:
import time, statisticsdef measure(client, prompt, max_tokens=1024, rounds=3):ttft_list, tps_list = [], []for _ in range(rounds):start = time.perf_counter()first = Nonen = 0for chunk in client.stream(prompt, max_tokens=max_tokens):if first is None:first = time.perf_counter()n += 1end = time.perf_counter()ttft_list.append((first - start) * 1000)tps_list.append(n / (end - first))return {"ttft_ms": round(statistics.mean(ttft_list), 1),"output_tps": round(statistics.mean(tps_list), 1),"p90_ttft_ms": round(sorted(ttft_list)[-1], 1),}
Only with a consistent methodology can you tell whether a given “speed improvement” comes from model optimization, a cache hit, or differences in the test environment.
5. Choosing by Scenario: Fast Does Not Mean Suitable
- Real-time interaction and voice conversation: prioritize time to first token, then throughput; it is worth sacrificing a small amount of quality to keep the interaction feeling responsive.
- Code completion and AI-assisted programming: extremely high throughput is required, because completions are often tens to hundreds of tokens and users have low tolerance for waiting; stability of structured output also matters.
- Long-document analysis and batch generation: prioritize throughput and unit cost; time to first token is acceptable, and asynchronous task queues are a good fit.
- Complex reasoning and high-precision extraction: prioritize capability, with speed secondary; a lightweight model can act as a front-end router, escalating only hard problems to a stronger model.
A practical architectural pattern is “tiered routing”: a lightweight, high-speed model handles most requests first, and confidence scores or rules determine whether escalation is needed, controlling cost while preserving the experience.
6. Supporting Engineering for Production
For high-speed inference to be genuinely usable, a complete support system is needed: a container platform to host elastically scaling inference services, a message queue to smooth peaks and fill valleys for batch tasks, object storage to archive inputs, outputs, and evaluation samples, and logging plus monitoring and alerting to track latency percentiles, error rates, and memory watermarks. If you use the relevant general-purpose capabilities of Baidu AI Cloud, these components can be combined as needed, avoiding the burden of building and operating everything yourself.
A regression evaluation set should also be established, bringing accuracy, throughput, tail latency, and unit cost into the same pipeline. Every model or parameter change runs through it, preventing a “faster but lower quality” regression from shipping unnoticed.
7. Conclusion
The value of the ultra-high-throughput data circulating in communities lies not in the specific numbers but in reminding developers that inference speed has become a core metric that can be engineered, measured, and optimized. Measure time to first token and throughput separately, benchmark with a consistent methodology, apply tiered routing by scenario, and equip the system with elasticity, asynchronous processing, and observability—this can significantly improve both experience and cost structure without changing model capability.
