Local LLM Inference Throughput: Benchmarking and Tuning Guide

    This article explains how to measure and tune local LLM inference throughput. It defines four distinct metrics (TTFT, steady-state decode speed, end-to-end throughput, and aggregate concurrent throughput), shows how memory bandwidth, weight size, KV cache, and multimodal encoding shape performance, and covers the real cost of long contexts, quantization and speculative decoding trade-offs, and a reproducible benchmarking method. Readers will learn how to turn vague "it feels fast" impressions into verifiable engineering conclusions.

    1. Define “Speed” Before Anything Else

    The most common argument in local model discussions is not about whose hardware is stronger, but about what “tokens/s” actually means. Without a shared definition, 120 tokens/s and 150 tokens/s may not be comparable at all. In practice, at least four metrics should be distinguished:

    • Time to first token (TTFT): the time from sending a request to receiving the first token, determined mainly by the prefill stage.
    • Decode throughput (decode tokens/s): the steady-state speed during token-by-token generation, usually what people mean when they say “speed” out loud.
    • End-to-end throughput: total tokens including prefill and all decoding divided by total elapsed time; with long prompts this is noticeably lower than steady-state decode speed.
    • Aggregate concurrent throughput: the total tokens produced per second by the server when multiple requests are in flight, which is a different dimension from single-stream speed.

    Single-stream speed is constrained by memory bandwidth, while aggregate throughput is constrained more by compute and batch scheduling. So the statement “my speed is 130” only means something once model size, quantization format, context length, whether multimodality is enabled, and concurrency are all specified.

    2. What Determines Throughput

    A reusable approximation is: single-stream decode speed ≈ memory bandwidth ÷ bytes of weights and cache moved per token. From this, a few stable conclusions follow:

    1. Parameter count and bit width together determine weight bytes, and quantization is the most direct way to improve single-stream speed.
    2. The KV cache grows linearly with context length, and long contexts continuously consume bandwidth budget.
    3. Multimodal input usually means larger vision encoding overhead and longer visual token sequences, which mainly weigh on the prefill stage.
    4. Speculative decoding and multi-token prediction reduce memory accesses by verifying multiple candidate tokens in a single forward pass; the payoff depends on the draft hit rate.

    The illustrative estimation logic can be written as:

    1. # Only to illustrate the order-of-magnitude relationship, not a concrete implementation
    2. bytes_per_token = params * bytes_per_weight + 2 * layers * kv_heads * head_dim * ctx_len * bytes_per_elem
    3. upper_bound_tps = mem_bandwidth / bytes_per_token

    Actual values will be lower than this upper bound because of fixed costs such as kernel launch overhead, sampling and post-processing, and scheduling gaps.

    3. The Real Cost of Long Contexts

    When you push the context to the level of over a hundred thousand tokens, the slowdown is often not a linear “it feels slower” effect but three stacked overheads: prefill compute grows with length; the KV cache stays resident in GPU memory and squeezes the available batch space; and how well the attention implementation matches the cache layout determines memory access efficiency. Practical recommendations:

    • Distinguish “fits” from “runs well.” Fitting only means memory did not overflow; running well depends on whether steady-state decoding is still within an acceptable range.
    • For long-document tasks, prioritize optimizing prefill; for long-form writing tasks, prioritize optimizing decode.
    • Run gradient tests with fixed prompt lengths, for example one round each at 4k / 16k / 64k / 128k, and plot the speed decay curve; that is more informative than a single data point.

    4. Trade-offs: Quantization, Speculative Decoding, and Multimodality

    Low-bit quantization (such as 4-bit weights) can significantly improve single-stream speed and reduce memory usage, but differences between quantization schemes in activation handling and scaling granularity cause accuracy fluctuations, and long-chain reasoning and code tasks are more sensitive to numerical error. The recommended approach is to first build a small evaluation set, compare task accuracy before and after quantization, and then decide whether the speed gain is acceptable.

    Speculative decoding and multi-token prediction show the most obvious gains on “thinking” outputs: when the model continuously produces long stretches of reasoning text, the candidate token hit rate is high and the effective speed can multiply; on highly branching tasks with frequent backtracking, the hit rate drops and the gain shrinks or even becomes negative. So evaluating these features must be tied to the real business prompt distribution, not just ideal samples.

    A common mistake in multimodal pipelines is counting vision encoding time into decode speed, which makes the numbers jump around. The proper approach is segmented timing, reporting vision encoding, prefill, and decode durations separately.

    5. A Reproducible Benchmarking Method

    1. # Pseudocode: fix input and output lengths, take steady state over multiple runs
    2. for ctx in [4096, 16384, 65536]:
    3. for run in range(5):
    4. t0 = now()
    5. stream = generate(prompt=pad_to(ctx), max_new_tokens=512, stream=True)
    6. first = next(stream); ttft = now() - t0
    7. rest = drain(stream); total = now() - t0
    8. record(ctx, ttft, 512 / (total - ttft))

    Key points include: fix the random seed and sampling parameters, discard the first warm-up run, report median and tail latency, and record GPU memory usage and whether thermal throttling is triggered at the same time. If you deploy on a container platform or a model serving framework, you should also separate queue wait time from server-side elapsed time; otherwise you are measuring scheduling capability rather than inference capability.

    6. Conclusion

    The value of speed discussions is not in producing the maximum number, but in establishing an alignable definition and locating bottlenecks. Splitting metrics into four layers—TTFT, steady-state decode, end-to-end, and aggregate throughput—combined with context gradient tests, before-and-after accuracy comparisons for quantization, and speculative hit rate statistics, turns “it feels fast” into verifiable engineering conclusions. When reproducing on the cloud, you can rely on general capabilities such as container platforms, object storage, logging services, and monitoring alerts to build a fixed environment, so every tuning effort has a solid basis.