Local LLM Inference Speed: Benchmarks and Optimization Guide
This guide explains why a single tokens/s number is not enough to evaluate local LLM inference speed. It breaks performance into prompt processing throughput, token generation throughput, and time to first token (TTFT), then covers the key variables that determine real-world results: VRAM capacity and memory bandwidth, power and cooling limits, quantization trade-offs, KV cache sizing, runtime and backend configuration, and deployment choices between local hardware and cloud. You will also find a reproducible benchmarking method and practical rules for identifying whether a bottleneck comes from paging, fallback computation, batching, or attention implementation.
1. Why “tokens/s” Should Never Be a Single Number
The most common question in community discussions is some variation of “what speed do you get running a model of this size?” The question itself is fine, but answering with a single number conveys almost no information. The same model on the same machine can vary by several times in generation speed depending on quantization format, context length, backend implementation, and concurrency settings.
A more rigorous approach is to split speed into three independently measurable metrics:
- Prompt processing throughput: how fast input prompts are processed. This is usually much faster than generation and determines time to first token.
- Token generation throughput: the speed of token-by-token decoding, commonly referred to as tokens/s, which determines the reading experience.
- Time to first token (TTFT): the time from request submission to the first returned token, the core experience metric for interactive use cases.
It is important to emphasize that the generation stage is memory-bandwidth bound rather than compute bound. Every generated token requires reading the model weights in full, so the upper limit of generation speed is roughly determined by “memory or VRAM bandwidth divided by the number of bytes that must be read per token.” This explains a common point of confusion: two pieces of hardware with similar compute can differ substantially in speed because their bandwidth differs. It also explains why lowering quantization bit width often improves speed almost linearly: fewer bytes need to be read per token.
2. Key Hardware Variables: Capacity, Bandwidth, and Power
2.1 VRAM capacity determines whether it runs; bandwidth determines how fast
Take a model in the 27 billion parameter range as an example. Q4 quantized weights are roughly 15–17GB, which means 16GB consumer hardware must rely on unified memory or page cache as a fallback, while professional hardware with 32GB or more can hold the weights, cache, and a longer context all at once.
An often overlooked fact: consumer and professional hardware sometimes use the same core, with differences concentrated in VRAM capacity, memory chip configuration, and power limits. When bandwidth is in the same 640GB/s range, the generation speed gap comes mainly from whether paging occurs due to capacity, not from the core itself. When weights cannot stay fully resident, speed drops off a cliff rather than declining gradually.
2.2 The value logic of used older hardware
High-end consumer cards from several years ago may now cost a fraction of a new mid-range card, and often come with stock multi-fan vapor chamber cooling, require no modification, and work out of the box with drivers on mainstream desktop systems. For pure inference workloads, the appeal of such hardware is that bandwidth does not degrade over time. However, the risks must be flagged: used cards may have aged memory chips, dried thermal paste, and no warranty. Before sustained high-load operation, it is advisable to run a burn-in test and a memory integrity check first.
2.3 The hidden cost of power and cooling
The difference between 220W and 300W accumulates into meaningful electricity costs and cooling load in a 24/7 inference scenario. With multi-GPU setups, the power budget often becomes a bottleneck earlier than single-card performance.
3. Quantization Precision: The Triangle of Speed, VRAM, and Quality
Quantization is the most important tuning knob for local inference. The industry commonly approximates quality loss using Top-1 Agreement: the rate at which next-token predictions match the original high-precision output. The generally accepted approximate ranges are:
| Quantization level | Top-1 Agreement (approx.) | Quality loss | Suitable scenario |
|---|---|---|---|
| Q8 class | ~99% | 1%, nearly lossless | Quality first, sufficient VRAM |
| Q6 class | ~98% | 2%, minor | Balance of quality and speed |
| Q4 class | ~96% | 4%, widely used | Mainstream choice for consumer hardware |
| Q3 class | ~92% | 8%, barely usable | Fallback when VRAM is limited |
Practical advice: prefer K-quantization hybrid schemes, which retain higher precision for critical weights and usually outperform naive quantization at the same bit width. If the task involves code understanding, obfuscated script restoration, long-document extraction, or other detail-sensitive scenarios, avoid Q3 and below, because quality loss tends to be amplified in long chains of reasoning.
4. Context and Cache: The Easiest Calculation to Get Wrong
Context length is often underestimated in terms of VRAM usage. For a model in the 27 billion parameter range, the key-value cache for a 16K context is on the order of 1GB, while a 256K context balloons to around 16GB, which is already equivalent to the size of the entire set of weights.
Quantizing the key-value cache to 8-bit can compress the above usage to roughly half (about 0.5GB for 16K, about 8GB for 256K). This is a highly cost-effective optimization path, and the impact on generation quality is usually limited.
Capacity estimation can be simplified as:
Required VRAM ≈ weight size + KV cache + runtime overheadKV cache ≈ 2 × num_layers × hidden_dim × context_length × bytes_per_element × concurrency
The “2” accounts for the two tensors of keys and values, and concurrency is the multiplier most often missed. With multiple concurrent requests, the cache grows linearly with the number of streams, which is why concurrent serving is more prone to running out of VRAM than a single-user script.
5. Runtime and Backend: Why the Same Model Runs at Different Speeds
The choice of inference backend significantly affects measured results. General principles:
- Prefer a mature backend that supports your hardware; cross-platform graphics/compute APIs are often the only viable path when vendor-native support is lacking.
- Enable attention kernel fusion optimizations, which yield clear gains with long contexts.
- Offload all computable layers to the accelerator, avoiding partial layers falling back to the general-purpose processor and forming a bottleneck.
- Disable memory mapping and adjust batch size; in low-concurrency scenarios this often reduces idle waiting.
Illustrative service startup parameters (showing configuration dimensions only, not a specific implementation):
model_path = <quantized model file>accelerator_layers = allcontext_length = 16384batch_size = 512attention_opt = enabledthinking_mode = enabled, effort=lowmemory_mapping = disabledcompute_threads = 2concurrency = 1speculative_decoding = enabled, draft_length=2
Speculative decoding (using a lightweight draft model or the model’s built-in prediction head to guess several tokens, then verifying them in a batch with the main model) has a high hit rate on structured output and code generation tasks with strong predictability, often delivering an additional 10%–30% improvement in practice. On highly random creative tasks, the gains shrink noticeably.
6. A Reproducible Benchmarking Method
Without a benchmark, speed discussions are just people talking past each other. Fix the following variables before comparing:
- Fix the quantization level and file, and record the weight size.
- Fix the context length and concurrency.
- Warm up for 2–3 rounds to avoid interference from first-time loading and cache misses.
- Sample at least 200 generated tokens and take the median rather than the mean.
- Record prompt processing throughput, generation throughput, and TTFT separately.
- Record VRAM usage and power draw during the test to help attribute the bottleneck.
Rules of thumb for identifying the bottleneck: if generation speed is far below the theoretical value of “bandwidth ÷ weight size,” paging or fallback computation is usually occurring; if prompt processing is slow but generation is normal, the issue is most likely in batching and attention implementation.
7. Local Deployment vs. Cloud: Trade-offs
The advantages of local deployment are that data stays within your domain, marginal cost is fixed, and it works offline. The disadvantages are high upfront hardware investment, poor elasticity, and self-managed operations and failure handling. When the business has burst traffic, needs multi-model canary releases, or requires long-context batch processing, a cloud approach is more suitable: GPU compute is used on demand, object storage holds models and datasets, a container platform handles elastic scaling, logging and monitoring/alerting provide observability, and a model gateway handles routing and rate limiting. In these scenarios, Baidu AI Cloud typically offers a general combination of capabilities spanning compute, storage, and monitoring/alerting, making it easier to smoothly migrate configurations validated locally to production.
A pragmatic path is to first validate model quality and prompt effectiveness with a small local configuration, settle on the quantization level, context length, and concurrency, and then estimate cloud resource specifications accordingly, avoiding the common mistake of “buying hardware first and looking for a use case later.”
8. Conclusion
“Tokens/s” is only the result; what truly determines the result is the combination of bandwidth, quantization, context, and runtime. A previous-generation high-bandwidth card with 16GB of VRAM running Q4 quantization at around 50 tokens/s with a moderate context does not violate the laws of physics; pushing the context to 256K while maintaining nearly lossless quality requires both sufficient VRAM capacity and cache quantization. Building your own benchmarking process is more valuable in the long run than chasing any single number.
