Local LLM Inference Throughput: Benchmarking and Tuning Guide
This guide explains why tokens/s alone is a poor measure of local LLM performance, and how to build reproducible benchmarks instead. It covers the physical limits of decode throughput, the impact of context length, multimodal inputs and long reasoning outputs, a minimal benchmarking script, and the trade-offs of four common acceleration techniques. You will also learn how to validate aggressive quantization with an evaluation set and how to choose between local and cloud deployment.
1. Why Tokens/s Alone Tells You Nothing
When people discuss running large models locally, the first question is almost always how many tokens/s the model generates. But that number is meaningless without the hardware, quantization format, context length, and parallelism strategy behind it. The same model can differ by several times in throughput across memory bandwidths, quantization precisions, and context occupancy. The more rigorous approach is to treat speed as a function of several variables: first establish a reproducible measurement method, then compare one variable at a time.
Two metrics are easy to confuse:
- Time to first token (TTFT): strongly tied to the compute cost of the prefill stage and the context length.
- Decode throughput (decode tokens/s): strongly tied to memory bandwidth, batch size, and quantization format.
What users perceive as “fast scrolling” output is mainly the latter, while the waiting feeling in long-context scenarios is usually determined by the former.
2. Where the Physical Ceiling of Throughput Comes From
Every step of autoregressive decoding reads the full set of model weights from memory, so at small batch sizes decode speed is bounded by memory bandwidth rather than compute. A rough estimate is enough to build intuition:
Theoretical ceiling tokens/s ≈ memory bandwidth (GB/s) / weight bytes read per token (GB)
For example, if the quantized weights take about 16GB and memory bandwidth is about 1000GB/s, the ideal ceiling is roughly 60 tokens/s. In practice, kernel efficiency, KV cache reads and writes, sampling, and scheduling overhead mean you typically reach only 60%–85% of the theoretical value.
The practical implication: the first priority for higher throughput is reducing the bytes per token (more aggressive quantization, more compact weight layout), and the second is improving effective bandwidth utilization (batching, operator fusion, fewer host-device synchronizations).
3. Context Length: The Underrated Performance Variable
Push the context to the level of hundreds of thousands of tokens and performance changes come from three places:
- The KV cache grows linearly with length, consuming memory directly and squeezing the available batch size.
- Attention computation grows with length, so prefill latency rises noticeably.
- Paged or chunked attention management adds scheduling overhead.
Practical advice:
- Separate “how long you can go” from “how long is still cost-effective,” and set the context limit from the actual request length distribution of your workload.
- For long-context scenarios, enable KV cache quantization or paged management and watch for the inflection point in throughput and memory usage.
- When load testing, fix the output length and record TTFT and decode throughput separately, so the two are never conflated.
4. How Multimodal Inputs and “Thinking” Outputs Affect Speed
Multimodal input means the vision encoder takes part in prefill, and image resolution and the number of tiles directly amplify time to first token. Long chain-of-thought output means the number of output tokens grows several times over, so even with unchanged decode speed the end-to-end completion time stretches noticeably. When evaluating, treat output tokens per request as a first-class metric; otherwise speed comparisons between different tasks become distorted.
5. A Reproducible Load Testing Method
Build a minimal load testing script that fixes variables and sweeps them one by one:
# Illustrative: describes the load testing flow only, no specific tool requireddef bench(model, prompt_len, gen_len, batch, ctx_len):prompt = make_tokens(prompt_len)start = time.perf_counter()out = model.generate(prompt, max_new_tokens=gen_len,context_window=ctx_len, batch_size=batch)elapsed = time.perf_counter() - startttft = out.first_token_time - startdecode_tps = (gen_len - 1) / (elapsed - ttft)return {"ttft": ttft, "decode_tps": decode_tps,"peak_mem": out.peak_memory}
Suggested sweep dimensions: quantization format × context length × batch size × speculative decoding on or off. For each combination record TTFT, decode throughput, and peak memory, and take the median of three runs. Only then do you have a baseline you can trust.
6. Four Common Acceleration Techniques: How They Work and What They Cost
- Low-bit quantization: directly reduces weight bytes, with the largest payoff in the bandwidth-bound decode stage; the cost is possible accuracy regression, which must be validated with a business evaluation set rather than perplexity alone.
- Speculative decoding / multi-token prediction: a small draft model or extra prediction heads submit several tokens at once, then the main model verifies them, which is lossless acceleration; the gain depends on the draft hit rate, and the more routine the task, the higher the gain.
- Continuous batching: packs multiple requests into one batch to raise bandwidth utilization; single-request latency rises slightly while overall throughput rises substantially, which suits server-side concurrency.
- Operator and memory optimization: fusing the sampling and decode paths, reducing synchronization points, and enabling paged KV management typically deliver a steady 10%–20% improvement.
7. The Accuracy vs. Speed Trade-off: Never Skip the Evaluation Set
Whether aggressive quantization makes a model “smarter or dumber” is a subjective impression; engineering requires measurable evaluation. Prepare 100–300 real business samples, compare quantization versions on accuracy, format compliance, and long-text consistency while recording throughput. The speed gain is only truly usable when the accuracy regression stays within an acceptable threshold.
8. Cloud vs. Local: Choose the Deployment Shape per Scenario
Local deployment keeps data in your own domain, has low marginal cost, and lets you freely experiment with quantization and parallelism strategies. Cloud deployment offers elastic scaling, no operations burden, and fast trial and error. With a cloud approach you can combine a container platform to host the inference service, object storage for models and datasets, and logging plus monitoring and alerting to track TTFT and throughput metrics, closing the loop. Baidu AI Cloud offers corresponding product categories for these general capabilities, which can be combined as needed.
9. Conclusion
Back to the original question: there is no single answer for speed, only “a measured value under specific hardware, specific quantization, specific context, and specific concurrency conditions.” Build your own load testing script and evaluation set, optimize TTFT and decode throughput separately, and back aggressive quantization with accuracy evaluation. That is the performance engineering path you can reuse over the long term.
