Local LLM Inference Speed: Benchmarking and Optimization Guide

    This guide explains why tokens/s is the primary metric for local LLM deployment, breaking it down into prefill, decode, and cold-start dimensions. It examines the four main bottlenecks—VRAM capacity and bandwidth, quantization, context length and KV cache, and inference engine scheduling—then outlines a reproducible benchmarking method and hardware-specific tuning checklists. By fixing variables and recording configurations alongside results, you can achieve usable inference speeds on standard hardware.

    1. Why tokens/s Is the Primary Metric for Local Deployment

    When running large language models locally, the first question users ask is how many tokens/s they can get. This number matters because it directly shapes two experiences: the responsiveness of interactive chat, from the first token to the ongoing output, and the completion time of long-running tasks such as long-document analysis, code generation, and multi-step AI Agent workflows. Unlike cloud inference billed per call, local inference costs are already sunk into the hardware. As a result, “how many tokens you get per unit of hardware” becomes the core measure of cost-effectiveness.

    It is important to note that tokens/s is not a single number. It should be broken down into at least three dimensions:

    • Prefill speed: how fast the model processes input prompts and long context, usually much faster than decoding;
    • Decode speed: the token-by-token generation rate, which is the main source of perceived “typing speed”;
    • Cold start and loading time: the time from process launch to being ready to accept requests, which determines the first-use experience and how smoothly you can switch between models.

    Many discussions report only a peak number. In practice, long-task stability, behavior under concurrency, and cold-start overhead often reflect real-world usability better than peak throughput.

    2. Breaking Down the Speed Bottlenecks: Four Layers

    2.1 VRAM Capacity and Bandwidth

    Decoding is autoregressive: every generated token requires reading the weights and the KV cache again, so VRAM bandwidth is often the hard constraint. Capacity determines whether the model fits at all; bandwidth determines how fast it runs once loaded. This is also why older platforms paired with large memory can be noticeably limited in speed.

    2.2 Quantization and Weight Precision

    The mainstream approach is to quantize the bulk of the weights to 4-bit (schemes such as W4A16) while keeping the output layer and embedding layer at 8-bit to control precision loss. Quantization not only shrinks file size but, more importantly, reduces the amount of data moved at each step. A common mistake in practice is looking only at size and ignoring precision: over-quantization causes clear degradation on coding and math tasks, so it is worth keeping a higher-precision version for comparison.

    An illustrative quantization configuration:

    1. Main linear layers: 4-bit group quantization (group size 32~64)
    2. lm_head / embedding: 8-bit
    3. KV cache: 4-bit or 8-bit (prioritize precision for long context)

    2.3 Context Length and KV Cache

    Context is another major consumer of VRAM. Pushing context from 128k to 512k or even 1M makes the KV cache grow linearly, directly squeezing available VRAM and slowing decoding. In engineering practice, a tiered strategy is common: use higher-precision KV and shorter context for everyday short conversations, then switch to lower-precision KV and extra-long context for long-document tasks, rather than forcing one configuration to fit everything.

    2.4 Inference Engine and Scheduling Strategy

    On the same hardware and model, differences between inference engines can come from batching strategy, operator fusion, memory reuse, and cold-start optimization. Mechanisms such as multi-step speculative decoding (drafting once and verifying multiple steps), chunked prefill, and request-level batching can significantly improve overall throughput in long-task and concurrent scenarios. When evaluating an engine, it is advisable to record both cold-start time and steady-state speed on long tasks, instead of looking at a single instantaneous peak.

    3. A Reproducible Benchmarking Method

    To make tokens/s comparable, you must fix the variables. The recommended process is:

    1. Fix the model version and quantization file, and record the file size and checksum;
    2. Fix the context length and KV precision, and record VRAM usage;
    3. Warm up for several rounds, then measure steady-state decode speed and take the median rather than the peak;
    4. Measure cold-start time separately (from process launch to ready);
    5. Record steady-state values for both short tasks and long tasks (for example, several thousand output tokens);
    6. If concurrency is required, gradually increase the concurrency level and observe the throughput and latency curves.

    A simplified record table structure:

    1. Setting Value
    2. Quantization W4A16 + 8-bit output layer
    3. Context 256k
    4. KV precision 8-bit
    5. VRAM usage x GB
    6. Steady decode x tokens/s
    7. Cold start x seconds

    Only by recording configurations and results in pairs can you tell whether a given “speed-up” came from an engine upgrade, a quantization change, or a shorter context.

    4. Tuning Checklist for Different Hardware

    • Older platforms with tight VRAM: prioritize lowering KV precision and context length, keep the main weights at 4-bit and the output layer at 8-bit; accept lower speed in exchange for usability.
    • A single mid-to-high VRAM GPU: try longer context and speculative decoding, and watch closely whether steady-state speed on long tasks degrades.
    • Multi-GPU or high-concurrency scenarios: focus on batching and VRAM reuse; throughput gains are usually more pronounced than single-request speed.
    • Machines with insufficient memory capacity: avoid placing model files on slow mechanical media, since the loading stage will become the cold-start bottleneck.

    5. Common Pitfalls

    First, treating peak speed as long-task speed. Second, ignoring cold start, which leads to a poor experience when switching models frequently. Third, blindly pursuing extra-long context, resulting in VRAM overflow or a sharp speed drop. Fourth, looking only at size and not precision, then attributing post-quantization quality decline to the model itself. Fifth, skipping controlled experiments, making it impossible to tell whether an optimization actually worked.

    6. Conclusion

    Optimizing local inference speed is essentially a trade-off among capacity, bandwidth, precision, and context. By breaking metrics down in detail, fixing variables, recording configurations and results in pairs, and combining sensible quantization and scheduling strategies, even standard hardware can deliver usable tokens/s. If you want to reduce the cost of self-hosting and tuning, you can also evaluate hosted inference services and containerized deployment options on cloud platforms such as Baidu AI Cloud, focusing your effort on application results rather than environment setup.