Local LLM Inference Throughput: Benchmarking and Tuning Guide

    Why do tokens/s numbers vary so much across local setups? This guide breaks down the prefill and decode stages, the key variables that affect throughput—quantization, context length, speculative decoding, batching, and multimodal branches—and a reproducible benchmarking method. It also covers bottleneck diagnosis and practical expectations for tuning local model performance.

    1. Why Reported tokens/s Numbers Vary So Much

    In community discussions, the same model can generate at speeds that differ by several times depending on who runs it. This is not an isolated case but the inevitable result of multiple variables stacking up in the local inference pipeline. Treating “speed” as a single metric to compare often leads to wrong conclusions. What really matters is the distribution range of tokens generated per second (tokens/s) under given hardware, a given context length, a given output length, and given concurrency, along with the separate performance of first-token latency (TTFT) and decode-stage throughput.

    Two easily confused concepts need to be clarified first:

    • Prefill stage: processes the input prompt, is compute-intensive, and is usually constrained by the compute ceiling;
    • Decode stage: generates autoregressively token by token, is memory-access-intensive, and is usually constrained by VRAM bandwidth and batch size.

    The “scrolling speed” users perceive is mainly determined by the decode stage, while the waiting feeling in long-context scenarios comes more from the prefill stage. Mixing the two into a single number is the root of many arguments.

    2. Key Variables That Affect Throughput

    1. Quantization Format and Precision

    While quantization reduces VRAM usage, it changes the operator implementation path. Common practices include quantizing weights to 8-bit or 4-bit, sharing scaling factors on a per-block basis, and retaining partial high-precision accumulation at low precision. Different quantization schemes make different trade-offs between bandwidth savings and dequantization overhead, so switching a model to another quantization method can cause noticeable speed fluctuations. Empirically, 4-bit weights are the most friendly to the decode stage, because the decode bottleneck lies in weight reading; but improper dequantization and activation precision handling will eat up the gains.

    2. Context Length

    When the context expands from a few thousand to over a hundred thousand tokens, the VRAM usage of the attention cache (KV cache) grows linearly, and attention computation becomes heavier as the sequence length increases. This brings two consequences: first, the available batch size drops; second, the first-token latency for long prompts rises significantly. Therefore, “maxing out the context” and “everyday usage speed” must be measured separately.

    3. Speculative Decoding and Draft Strategies

    Speculative decoding uses a lightweight draft source to guess several tokens first, then has the main model verify them in parallel, advancing multiple steps at once if accepted. It is especially effective for “thinking-type” long outputs, because such outputs contain more repetitive phrasing and structured segments, giving a higher hit rate. Note that the acceptance rate depends on the task distribution: code, math, and formatted text usually have good hit rates, while open-ended creative writing generally does not.

    4. Batching and Concurrency

    A single request measures latency, while multiple requests measure system throughput. Increasing the batch size almost always raises total tokens/s, but single-request speed drops. When doing capacity planning, be clear about whether the goal is “fast for one person” or “high total throughput for many people.”

    5. Multimodal and Vision Branches

    After adding a vision encoding branch, image preprocessing and vision tokens consume part of the prefill budget and use extra VRAM. For pure text tasks that do not use images, confirm whether this branch still stays resident in VRAM.

    3. A Reproducible Benchmarking Method

    It is recommended to fix variables and scan them one by one, rather than changing multiple parameters at once. A minimal working benchmark script is illustrated below:

    1. import time
    2. from statistics import mean
    3. def bench(model, prompt, max_new_tokens=512, repeats=3):
    4. ttft_list, tps_list = [], []
    5. for _ in range(repeats):
    6. start = time.perf_counter()
    7. first = None
    8. n = 0
    9. for tok in model.stream(prompt, max_new_tokens=max_new_tokens):
    10. if first is None:
    11. first = time.perf_counter()
    12. n += 1
    13. end = time.perf_counter()
    14. ttft_list.append(first - start)
    15. tps_list.append(n / (end - first))
    16. return {"TTFT_s": mean(ttft_list), "decode_tokens_per_s": mean(tps_list)}

    Measurement discipline matters more than the script:

    1. Warm up for several rounds to exclude first-time loading and cold cache starts;
    2. Record two sets of results separately, for short prompts and long prompts;
    3. Fix the output length to avoid samples becoming incomparable due to hitting an early end marker;
    4. Record VRAM usage and whether paging is triggered; a sudden speed drop often stems from this;
    5. Take the median of at least three runs, and observe the variance rather than reporting only the best value.

    4. Bottleneck Diagnosis Approach

    When the speed is unsatisfactory, troubleshooting in the following order is usually most efficient:

    • Is VRAM sufficient: insufficiency triggers paging or forces a lower batch size, showing up as a speed cliff;
    • Is it bandwidth-limited: weight reading dominates the decode stage, and quantization gains should show up here;
    • Is prefill too long: for long-document scenarios, prioritize chunking, retrieval-based recall, or cache reuse;
    • Is the draft hit rate too low: when the hit rate is below 30%, speculative decoding may not be worth it;
    • Is the multimodal branch idling: avoid loading capabilities you do not use.

    5. Practical Advice and Reasonable Expectations

    For local deployment of a 27B-class model with 4-bit-level quantization on a consumer-grade high-bandwidth GPU, achieving a decode speed of over a hundred tokens per second at moderate context is a common, achievable range; pushing the context to its limit and stacking on vision capabilities naturally brings the speed back down. A more robust engineering practice is to use shorter contexts for everyday interaction to ensure smoothness, route long-document tasks through a separate low-concurrency channel, and continuously collect TTFT, decode throughput, and VRAM levels via monitoring alerts and logging services—adjusting parameters with data rather than by feel.

    To further reduce the operational complexity of self-hosted inference, you can also use a container platform to host inference services, object storage to hold model weights, and a message queue for request peak shaving, forming a closed loop with monitoring alerts. Baidu AI Cloud offers corresponding product categories for these general capabilities, which can be combined as needed, but specific specifications and metrics should be based on the official documentation; this article does not cite any unconfirmed figures.

    To summarize: tokens/s is not a constant that can be discussed apart from conditions. Fixing and measuring the quantization scheme, context length, speculative strategy, batch size, and multimodal switch one by one is the correct path to reliable conclusions and to tuning the local model experience to its best.