Local LLM Inference Throughput Optimization: A Practical Guide

    This guide explains why local LLM inference speed is a multi-variable problem rather than a single tokens/s number. It breaks down the core factors affecting throughput—context length, quantization format, memory bandwidth, sparse MoE architectures, and inference engine scheduling—and outlines a reproducible benchmarking method and a recommended tuning workflow for planning capacity around steady-state performance.

    1. The Core Problem: Why Local Inference “Speed” Is a Multi-Variable Issue

    When deploying large language models locally, the metric most often discussed in the community is tokens generated per second (tokens/s). However, treating speed as a single number to compare often leads to contradictory conclusions. In real-world use, there are at least four distinct kinds of “speed”:

    1. Cold-start speed: the time from process launch to accepting the first request, including weight loading, VRAM/memory allocation, and cache and graph construction.
    2. Prefill throughput: the parallel compute capability when processing long prompts, usually strongly correlated with compute power and batching strategy.
    3. Decode throughput: the speed of the token-by-token autoregressive generation stage, usually limited by memory bandwidth and memory access efficiency.
    4. Long-task steady-state speed: the stable value reached after generating tens of thousands of tokens continuously, shaped by cache growth, longer context, thermal throttling, and other factors.

    So a responsible way to state results is not “I hit X tokens/s,” but “what is the steady-state value under this hardware, this quantization, this context length, and this stage.”

    2. Breaking Down the Core Variables That Affect Throughput

    2.1 Context Length: The Most Underestimated Performance Killer

    The attention cache grows linearly with context length, and attention computation itself becomes significantly more expensive over long sequences. The same model may decode several times slower at a 32K context than at a 1M context. The practical recommendation is to not treat “maximum supported context” as an everyday setting, but to define tiers based on actual task needs—for example, a smaller tier for daily conversation and a long-context tier for long-document analysis.

    2.2 Quantization Format: A Trade-off Between VRAM Capacity and Compute Efficiency

    A common approach is to use integer quantization at the 4-bit level for weights, so that a larger parameter scale fits in limited VRAM. But more aggressive quantization is not always better: too low a bit width may cause precision loss, and some operators introduce extra overhead during dequantization. In practice, first ensure the model fits entirely in VRAM, then consider raising the bit width in exchange for quality.

    2.3 Hardware Bandwidth and the Reality of Older Platforms

    The decode stage is closer to a memory-access-intensive task, so memory bandwidth often matters more than peak compute. Older platforms (for example, DDR3 memory or previous-generation consumer GPUs) can still deliver a usable experience with reasonable quantization and engine optimization, but require compromises on context length.

    2.4 A New Option from Sparse Activation Architectures (MoE)

    Sparse architectures with a large total parameter count but only a small number of parameters activated per token can push decode speed very high while retaining a large knowledge capacity. The cost is higher VRAM/memory usage and greater demands on total capacity. For everyday tasks centered on tool calling and agent orchestration, the cost-performance of such architectures is often better than that of dense models with “more parameters but full activation.”

    2.5 Inference Engines and Scheduling Strategies

    Performance differences for the same model across inference engines can exceed hardware differences. Key capabilities include paged cache management, continuous batching, prefix reuse, quantized operator fusion, and streaming weight loading during cold start. Parameters in the launch script—such as parallelism, cache tier, and batch size—need to match the hardware specs and cannot be copied from someone else’s configuration.

    3. A Reproducible Measurement Method

    It is recommended to build a benchmark table that fixes all other variables and changes only one dimension:

    1. | Model size/architecture | Quantization | Context tier | Cold start (s) | Prefill (t/s) | Decode steady-state (t/s) | Notes |
    2. |-------------------------|--------------|--------------|----------------|---------------|---------------------------|-------|
    3. | Dense 27B class | 4-bit | 32K | | | | |
    4. | Sparse A3B class | 4-bit | 128K | | | | |

    Measurement key points:

    • Use the same prompt and the same sampling parameters to avoid interference from randomness;
    • Record the rate of the “thinking phase” and the “final output phase” separately, as the two often differ by 20%~40%;
    • For long tasks, run continuously for at least 10 minutes before taking the steady-state value;
    • Record VRAM usage and temperature at the same time to determine whether throttling occurs.

    An illustrative stress-test loop:

    1. def bench(model, prompt, max_tokens=2048, ctx=32768):
    2. start = time.perf_counter()
    3. out = model.generate(prompt, max_tokens=max_tokens, ctx_len=ctx)
    4. dur = time.perf_counter() - start
    5. return len(out.tokens) / dur, out.tokens
    1. Define the task profile: long-document understanding, code generation, or high-frequency tool calling.
    2. Set the context tier first, then choose the model size, and finally tune the quantization bit width.
    3. Prioritize inference solutions that support paged cache and prefix reuse to improve cold start and repeated-prompt scenarios.
    4. Enable cache reuse for long tasks, keeping the system prompt and tool descriptions fixed in the prefix.
    5. Use steady-state values rather than peak values for capacity planning, and reserve a 20% margin.
    6. Freeze the final configuration into a versionable launch script, incorporate monitoring and alerting, and continuously observe latency and throughput drift.

    5. Conclusion

    Optimizing local inference speed is essentially a joint optimization of four factors: context length, quantization bit width, memory bandwidth, and engine scheduling. For most developers, rather than chasing a single peak number, it is better to configure tiers by task, plan around steady-state throughput, and continuously regress with a unified benchmark table. When daily tasks are mainly agent orchestration and tool calling, sparse activation architectures paired with a mature inference engine can often deliver a more balanced experience on older hardware; larger dense models are better suited to offline batch-processing scenarios with higher quality requirements.