LLM Inference Throughput Benchmarking and Tuning Guide
This guide explains why tokens/s numbers are hard to compare across setups and how to benchmark local LLM inference rigorously. It covers TTFT versus decode and end-to-end throughput, KV cache costs in long contexts, quantization trade-offs, speculative decoding, multimodal and long reasoning workloads, and a practical tuning checklist for reproducible performance.
1. Where the Problem Starts: Why “tokens/s” Is Hard to Compare
In community discussions, “how many tokens/s does this model get on my machine” is both the most common question and the most easily misread one. The same model on the same accelerator can produce numbers that differ by several times across users, and the cause is usually not the hardware but different measurement definitions and runtime configurations. To get a conclusion worth referencing, fix the variables first, then talk about numbers.
A few frequently conflated concepts need to be defined up front:
- Time to first token (TTFT): the time from sending the request to receiving the first token, determined mainly by the prefill stage and strongly correlated with input length.
- Generation throughput (TPS): the number of tokens produced per second during decoding, which is what most people mean by “speed.”
- End-to-end throughput: the aggregate measure including queuing, prefill, decoding, and post-processing, which is closer to real business experience.
- Batch throughput: total system output when many requests run concurrently, usually far higher than the single-stream number.
High single-stream decode speed does not imply good performance under concurrency, and vice versa. So any speed conclusion should carry three pieces of context: “single stream or concurrent,” “input length,” and “output length.”
2. Making Measurements Rigorous: A Reproducible Benchmarking Method
Fix the following variables before recording data:
- Fix input length (for example, one group each at 1k / 8k / 32k / 128k) and fix output length (for example, 512 tokens);
- Eliminate jitter from randomness by fixing sampling parameters;
- Run several warm-up rounds to exclude first-time loading and cold caches;
- Record VRAM usage, power draw, and temperature to judge whether you hit the power wall or the VRAM bandwidth limit;
- Repeat the same configuration at least three times and take the median.
A sketch of a benchmarking script skeleton follows (pseudocode, expressing only the flow):
def bench(model, prompt_len, output_len, runs=3):results = []for _ in range(runs):prompt = build_prompt(prompt_len)t0 = now()first_token_at = Nonen = 0for tok in model.generate(prompt, max_new_tokens=output_len):if first_token_at is None:first_token_at = now()n += 1total = now() - t0results.append({"ttft": first_token_at - t0,"tps": (n - 1) / (total - (first_token_at - t0)),})return median(results)
The key is to measure TTFT and decode throughput separately; otherwise, numbers in long-input scenarios are heavily polluted by prefill.
3. Long-Context Decay: KV Cache Is the Main Cost
When the context is pushed to the hundreds-of-thousands level, the slowdown is usually not because “the model cannot compute,” but because KV cache VRAM usage and memory access overhead grow linearly with sequence length. During decoding, every generated token requires reading the entire history cache, so under long context, VRAM bandwidth often becomes the bottleneck before compute does.
Possible mitigations include:
- Paged cache management to reduce fragmentation and reserved waste;
- Sliding-window or layered caching that selectively retains very long history;
- Prefix reuse, caching fixed parts such as system prompts and long documents to avoid repeated prefill;
- Cache quantization (trading a very small amount of precision for a significant capacity reduction), with an assessment of the impact on long-range consistency.
A more practical engineering approach is layering: make the resident fixed prefix a reusable cache, and keep a one-off long document reusable within the session, avoiding recomputation every turn.
4. Quantization Format and “Smartness”
Low-bit quantization (such as 4-bit level, and floating-point formats using 8-bit scaling blocks) can significantly reduce weight reads, so it often directly improves throughput during decoding. But one common misconception needs clearing up: quantization does not make a model smarter; it is a trade-off between precision and cost within the given model capability boundary.
The practical differences among quantization schemes show up in three places: first, per-layer sensitivity differs, with attention and embedding layers usually more fragile; second, if the calibration data distribution deviates from the actual task, errors are amplified on tasks such as long-text reasoning and code generation; third, kernel implementation quality determines the actual speedup, and theoretical compression ratio does not equal measured speed.
So the recommendation is: first compare task metrics before and after quantization on a small evaluation set, then decide whether to ship; for precision-sensitive outputs (numeric computation, structured extraction), keep a higher-precision path.
5. Speculative Decoding and Multi-Token Prediction
The core idea of speculative decoding is to use a lightweight draft path to propose multiple candidate tokens at once, then have the main model verify them in parallel, advancing multiple steps at once if accepted. Its benefit depends heavily on the draft hit rate: with a high hit rate, decode throughput can multiply; with a low hit rate, it becomes slower due to verification overhead.
Related to this, multi-token prediction lets the model predict multiple positions at once during training or inference, used together with a dedicated verification flow. Practical points:
- The draft source must be close to the main model’s distribution, otherwise the acceptance rate is extremely low;
- Higher temperature and more open-ended tasks usually mean lower acceptance rates;
- In batch scenarios the benefit is diluted, so benchmark it separately;
- Always use end-to-end throughput rather than single-step speedup as the evaluation metric.
6. Multimodal and “Big Thinking” Workloads
Workloads with visual input introduce extra encoding and projection overhead. Image resolution and the number of tiles directly determine the scale of visual tokens, which in turn affects prefill time. Designing cache strategies separately for the vision branch and the language branch avoids repeated image encoding.
For long-chain reasoning output, output length itself becomes the dominant variable: a screen full of thinking content means more decode steps, and throughput gains are partly offset by the longer output. The user experience depends on “how much content streams out per second” rather than a single-point TPS. Evaluating such scenarios should also record the output length distribution.
7. A Tuning Checklist
- Measure the baseline first: fix input and output length, and record TTFT, TPS, VRAM, and power;
- Then find the bottleneck: VRAM bandwidth, compute, or the power wall;
- Verify one item at a time: quantization format, cache strategy, speculative decoding, batch size, changing only one thing at a time;
- Watch concurrency: the best single-stream configuration is often not optimal under concurrency;
- Build regression checks: put the evaluation set and benchmarking script into continuous integration to prevent performance and precision regressions after updates.
8. Conclusion
“How many tokens/s” means nothing by itself. A meaningful conclusion is “under what input and output length, what quantization and cache configuration, single stream or concurrent, how much throughput you get, and how much precision is lost.” Only by standardizing measurement definitions, clearly locating the bottleneck, and verifying each optimization separately can you achieve stable, reproducible, deliverable performance on your own hardware.
