Local LLM Inference Speed: Benchmarking and Tuning Guide

    This guide explains why a single tokens/s number is an incomplete measure of local LLM performance, separating time to first token (TTFT) from steady-state decode throughput. It breaks decode speed into a practical model based on weight bytes, KV cache size, and effective memory bandwidth, then walks through VRAM budgeting, quantization choices (3-bit, 4-bit, 6-bit, plus KV cache precision), and four ways to improve decode speed, including speculative decoding, engine scheduling, storage, and MoE architectures. It also covers reproducible measurement practices and tiered hardware recommendations for 12GB and 20GB-class setups.

    1. The Problem: Why “tokens/s” Is an Incomplete Question

    In community discussions, “how many tokens/s does your model run” is almost always the first question asked. But a single number can be misleading: two dense models with the same nominal 27B parameter count can differ severalfold in measured throughput depending on VRAM capacity, quantization format, context length, inference engine, and storage medium. A more useful question is: under a given hardware budget, context length, and task type, what are the steady-state throughput and time to first token?

    First, separate two metrics that are often confused:

    • Time to first token (TTFT): strongly tied to prompt length, prefill compute, and context cache hit rate. It determines how long you wait after pressing Enter before text starts appearing.
    • Decode throughput (tokens/s): strongly tied to VRAM bandwidth, batch size, and quantization/dequantization overhead. It determines how fast the text streams out.

    A typical mid-range configuration provides a useful reference point: 12GB-class VRAM paired with 32GB of system memory, running a 3-bit-level quantized 27B dense model at 16K context with no additional speculative decoding, yields a TTFT of roughly 0.6–0.7 seconds and steady decode speed around 20 tokens/s. The number is not impressive, but in a local environment with zero marginal cost, it is already usable for lightweight Q&A and code completion.

    2. Breaking Throughput into a Computable Model

    Understanding the tuning space requires a rough but practical formula-based view:

    1. Per-token decode time ≈ bytes read per token / effective VRAM bandwidth + compute and scheduling overhead
    2. Bytes per token ≈ weight bytes + KV cache bytes per token
    3. KV cache bytes ≈ 2 × layers × KV heads × head_dim × precision bytes × context length

    This yields three practical conclusions:

    1. Whatever does not fit in VRAM will drag down speed. Once weights spill into system memory, traffic goes over PCIe rather than VRAM bandwidth, and speed drops off a cliff.
    2. Longer context means a larger KV cache. At long context lengths, the KV cache can even exceed the weights themselves and become the dominant bandwidth consumer.
    3. KV cache quantization is the most cost-effective lever for long-context scenarios. It typically compresses cache usage by more than half with limited accuracy impact on most tasks.

    3. VRAM Budget: Do the Math Before Choosing Quantization

    Using 12GB of VRAM as an example, here is a practical budget allocation:

    Item Budget Notes
    Weights 7–8GB A 27B model at 3-bit level is about a 14GB file, requiring partial offload or lower quantization
    KV cache 1.5–2.5GB With KV quantization enabled, 16K–32K context is relatively safe
    Runtime/framework overhead 1–1.5GB Compute graphs, temporary buffers, display output
    Headroom 0.5GB or more Avoid hitting the VRAM ceiling and triggering frequent paging

    A common mistake is blindly chasing ultra-long context. Forcing a 240K context into 22GB of VRAM will start, but the KV cache consumes most of the bandwidth budget and decode speed drops accordingly. Set context length by actual task needs, not by the hardware limit.

    4. How to Choose a Quantization Format

    When choosing among 3-bit, 4-bit, and 6-bit, follow the order of “satisfy VRAM first, then talk accuracy”:

    • 3-bit level: friendliest to VRAM, suitable as a baseline for “can it run at all”; degradation is relatively noticeable for long-text reasoning and math tasks.
    • 4-bit level: the most common engineering balance point today, with acceptable accuracy loss for most general tasks.
    • 6-bit and above: nearly doubles VRAM requirements, usually only worth it when VRAM is plentiful.

    Also do not overlook KV cache precision as an independent dimension: weights at 4-bit with KV at 4-bit often delivers a better long-context experience than “weights at 3-bit with unquantized KV.”

    5. Four Ways to Improve Decode Speed

    1. Speculative decoding / multi-token prediction: a small model or draft head guesses several tokens first, then the main model verifies them in parallel. In suitable configurations, this can bring a 30%–50% decode improvement, but it is sensitive to prompt style and may stop working after a task switch.
    2. Engine and scheduling optimization: inference implementations differ greatly in how they schedule prefill and decode, and long-task stability can vary significantly; cold start time can also differ by severalfold.
    3. Reduce cold start overhead: keeping model files on a slow mechanical hard drive noticeably lengthens load time; switching to solid-state storage is one of the cheapest optimizations.
    4. Architecture choice: mixture-of-experts (MoE) models activate only part of the experts at the same “total parameter count,” and decode speed is usually significantly better than dense models, making them an important option for local interactive scenarios.

    6. Make Measurements Reproducible

    Without reproducible measurement, discussion is meaningless. Fix the following variables before comparing:

    1. Fixed: model quantization version, context length, KV precision, engine version, speculative decoding on/off
    2. Recorded: TTFT, steady-state decode speed, average speed on long tasks (>4K output), peak VRAM, cold start time
    3. Task set: several short Q&A / long-document summarization / code generation prompts each, take the median rather than a single peak

    It is worth emphasizing: a peak speed that flashes by in the logs cannot serve as a conclusion; the steady-state value under long tasks reflects the real experience.

    7. Practical Recommendations: Tiered Selection

    • Entry (12GB-class VRAM): 3–4-bit quantization + 16K context + KV quantization, positioned for lightweight Q&A and completion; around 20 tokens/s is acceptable.
    • Advanced (20GB-class VRAM): 4-bit quantization + 32K–64K context with speculative decoding, steady state can exceed 30 tokens/s.
    • Interaction first: switch to an MoE model with fewer activated parameters, trading total parameters for speed; the experience improvement is most noticeable for daily agent-type tasks.

    If you want to avoid the cost of self-hosting and tuning, you can also evaluate pay-as-you-go general inference services or model hosting capabilities in the cloud, leaving VRAM and concurrency to the platform; local deployment is better suited to scenarios where data cannot leave the domain, offline operation is required, and marginal cost is zero. The two paths are not mutually exclusive; layering and mixing them by task sensitivity and concurrency is usually the more pragmatic engineering choice.

    8. Conclusion

    The real goal of local inference is not a benchmark score, but finding the balance point of “usable speed + acceptable accuracy + controllable context” on given hardware. Do the VRAM math first, then choose quantization, then consider the engine and speculative decoding, and finally verify with reproducible measurement—this order is more valuable than any single number.