Local LLM Inference Throughput Optimization: A Practical Guide
This article explains why raw tokens/s numbers are misleading without context, breaking down the distinct performance profiles of prefill and decode stages. It covers the key variables that affect local inference speed—context length, speculative decoding hit rate, and quantization formats—and provides a vendor-neutral tuning checklist, configuration example, and common pitfalls for achieving reproducible throughput gains.
1. The Starting Problem: Why “tokens/s” Is an Imprecise Question
When developers discuss local model speed, the most common question is “how many tokens/s does your model run?” From an engineering perspective, however, this number is almost meaningless without qualifying conditions. A complete inference request involves at least two stages with fundamentally different performance characteristics:
- Prefill: Processes all input tokens at once. It is compute-intensive and typically reaches hundreds or even over a thousand tokens/s.
- Decode: Generates output autoregressively, one token at a time. It is constrained by VRAM bandwidth and memory access efficiency, usually running at only tens of tokens/s.
A responsible statement should therefore be: “Under a specific quantization format, context length, and batch/speculative decoding configuration, prefill runs at roughly X tokens/s and decode at roughly Y tokens/s.” This article uses that framework to discuss how to systematically improve local inference throughput.
2. Performance Profiles of Prefill and Decode
Developers have reported that in their test environments, prefill can exceed 900 tokens/s at longer context lengths, while decode falls in the 40–70 tokens/s range. This gap is not abnormal; it is determined by the nature of the two workloads.
The prefill stage treats the entire input sequence as a single large-scale matrix operation with high arithmetic intensity, fully utilizing the hardware’s compute units. Its throughput ceiling therefore depends mainly on compute capacity and implementation efficiency. The decode stage processes only one new token per step but must repeatedly read all model weights and the KV Cache. This is a classic memory-bound workload whose ceiling is approximately the VRAM bandwidth divided by the number of bytes moved per step.
Understanding this naturally splits the optimization strategy: improving prefill relies on better operator implementations, batching, and parallelism; improving decode relies on reducing the data moved per step—that is, quantization, KV Cache compression, and speculative decoding that produces multiple tokens at once.
3. Key Variables Affecting Speed
3.1 Context Length
The longer the context, the larger the KV Cache that must be read at each decode step, and the more pronounced the slowdown. When the context reaches hundreds of thousands of tokens, the KV Cache itself can consume a considerable amount of VRAM, further shrinking the available batch space. In practice, capacity planning should be based on “typical context length” rather than “maximum supported length.”
3.2 Speculative Decoding Hit Rate
The core logic of speculative decoding (including multi-token prediction schemes) is to use a lightweight method to guess several tokens first, then have the main model verify them all at once, advancing multiple steps on a hit. The hit rate directly determines the speedup. In highly structured coding tasks, the hit rate is usually good; in open-ended generation and creative writing, the hit rate drops and the benefit shrinks accordingly. This explains why speed varies noticeably across tasks under the same configuration.
3.3 Quantization Format and KV Cache Precision
Weight quantization (such as 4-bit unbiased quantization schemes) significantly reduces the bytes moved per step and is the most direct lever for speeding up decode. Using 8-bit quantization for the KV Cache strikes a balance between precision and VRAM usage. Note that quantization is not lossless; too low a precision may cause output quality regression and must be validated against a task evaluation set.
4. An Actionable Tuning Checklist
Below is a general, product-agnostic tuning order. It is recommended to validate step by step and quantify the benefit of each item:
- Fix the evaluation baseline first: Standardize input length, output length, temperature, and sampling parameters, and record both prefill and decode metrics.
- Prioritize weight quantization: Choose a lower-bit quantization format as long as quality is acceptable.
- Compress the KV Cache: Enable 8-bit-level KV quantization and observe stability under long contexts.
- Tune speculative decoding depth: For coding tasks, start at 4; setting it too high introduces verification overhead and lowers the hit rate.
- Control batch and concurrency: Single-user low latency and multi-user high throughput are two separate parameter sets—do not mix them.
- Lock down a reproducible environment: Pin the runtime version and compiler options to avoid “it gets slower after a version change.”
Illustrative configuration snippet (pseudocode, expressing parameter relationships only):
config = {"weight_quant": "4bit", # Weight quantization; affects decode bandwidth"kv_cache_quant": "8bit", # KV compression; affects long-context performance"speculative_depth": 4, # Speculative / multi-token prediction depth"context_len": 262144, # Plan for capacity, not peak"batch": {"latency": 1, "throughput": 8},}
5. Trade-offs Between Frameworks and Toolchains
A recurring lesson is that speed and output quality can involve a trade-off across different inference implementations. Some high-performance solutions trade throughput for more aggressive graph optimization and scheduling, but may be less stable than conservative configurations on complex reasoning tasks. Selection should therefore not look at peak tokens/s alone; instead, evaluate three metrics simultaneously on a fixed evaluation set: throughput, time to first token, and task accuracy.
A more robust engineering approach is to abstract a unified inference interface that makes quantization format, speculative depth, and context limits configurable, so business code stays unchanged when switching implementations. If multi-machine or elastic scaling is needed, throughput, latency, and VRAM usage can be made continuously observable by combining common cloud capabilities such as container platforms, logging services, and monitoring/alerting.
6. Common Pitfalls
- Reporting only peak numbers without conditions: Speed figures detached from context length and quantization format are meaningless.
- Blindly increasing speculative depth: When depth is too large, verification costs rise and the hit rate drops, actually making things slower.
- Planning capacity with maximum context: This causes VRAM to be filled by the KV Cache, sharply reducing actual concurrency.
- Ignoring quality regression: Quantization and aggressive optimizations must be gated by a business evaluation set.
7. Summary
Optimizing local LLM inference throughput is essentially about making a controllable trade-off among compute, VRAM bandwidth, and output quality. First measure prefill and decode separately, then proceed in the order of “quantize weights → compress KV → tune speculative depth → tune concurrency,” and finally lock in the gains with a unified evaluation baseline. This yields performance that is fast, stable, and reproducible.
