Running Large Models on Old Hardware: A Practical Guide to 450 tok/s Inference Optimization

    This article explains how to achieve high-throughput local LLM inference on aging hardware, using a real optimization path that reached roughly 450 tok/s. It covers where the true bottlenecks lie (memory capacity, memory bandwidth, host-device interconnect, and CPU scheduling overhead), and three complementary layers of optimization: custom decode-oriented kernels, KV cache compression, and speculative decoding. It also outlines a reproducible profiling workflow that attributes a 51% throughput gain from a 298 tok/s baseline, plus deployment advice for old platforms such as PCIe 3.0 systems.

    1. Background: Where the Real Bottleneck in Local Inference Lies

    When deploying large models locally, developers often focus on GPU compute. In practice, the bottleneck is multi-layered: VRAM capacity determines whether weights and cache fit at all, memory bandwidth determines how many bytes must be moved per generated token, host-device interconnect bandwidth governs weight loading and cache swapping, and CPU single-core performance plus memory latency affect scheduling, sampling, and the overhead of speculative decoding decisions.

    A typical observation: running the same model on a nearly ten-year-old platform limited to PCIe 3.0, where theoretical bandwidth is far below newer systems, can still yield very high throughput after software-level optimization. This shows that during the decode phase (token-by-token generation), the workload is dominated by the number of weight and cache bytes that must be read per token and by memory-access parallelism, rather than by peak floating-point compute alone. Understanding this is the starting point for all the optimizations that follow.

    2. Overall Approach: Kernel-Level and Algorithm-Level in Tandem

    High-performance local inference is rarely a single trick. It usually advances on three fronts at once:

    • Kernel level: hand-write or deeply tune dedicated kernels for the key decode-phase operators, cutting redundant memory access and raising parallelism.
    • Representation level: compress the context cache to reduce bandwidth pressure under long contexts.
    • Algorithm level: use speculative decoding to turn “one token per pass” into “verify multiple candidate tokens at once.”

    The gains multiply rather than add, which is what produces stable, order-of-magnitude-level improvements on constrained hardware.

    3. Key Optimization 1: Custom Kernels for Decoding

    General-purpose operator libraries target batched throughput, whereas single-request decoding is a “thin and tall” workload: one dimension of the matrix shapes is close to 1, so generic implementations struggle to saturate the memory channels. A common practice is to provide dedicated paths for three categories of operators:

    1. Vector-matrix multiplication (GEMV-like): rearrange weights into a memory-access-friendly layout, combined with tiling and vectorized loads so each thread reuses more data in registers.
    2. Normalization and elementwise fusion: fuse normalization, scaling, and activation into neighboring operators to avoid repeatedly writing intermediate tensors back to VRAM.
    3. Gating/state-update operators: for stateful structures (such as linear attention or gated recurrence), reduce the number of state reads and writes.

    Illustrative scheduling pseudocode (to convey the fusion and tiling idea, not a specific API):

    1. for tile in weight_tiles:
    2. acc = load_accumulator()
    3. for k in tile.k_blocks:
    4. w = vectorized_load(tile, k)
    5. x = broadcast_load(x_cache, k)
    6. acc = fused_dot_add(acc, w, x) # fused multiply-add, avoids intermediate write-back
    7. store_partial(acc)

    The key point: eliminating one round trip to VRAM often matters more than gaining a few percentage points of compute utilization.

    4. Key Optimization 2: Compressing the Context Cache

    The KV cache expands quickly with long sequences, becoming a burden on both bandwidth and capacity. Compression approaches typically include lowering cache precision, pruning or merging less important history entries, and grouped sharing across attention heads. Engineering-wise, two things must be monitored together: how much bandwidth the compression saves, and whether generation quality stays acceptable. A sensible approach is to expose configurable levels, letting users trade off between “long context remains usable” and “speed first.”

    5. Key Optimization 3: The Benefits and Costs of Speculative Decoding

    In speculative decoding, a small, fast draft generator guesses several tokens first, then the large model verifies them in parallel in a single pass; if accepted, it advances multiple steps at once. The benefit depends heavily on the acceptance rate:

    1. effective_tokens_per_pass = 1 + accepted_length
    2. speedup ≈ effective_tokens_per_pass / (1 + draft_overhead_ratio)

    In the original context, draft generation took about 3.5 ms and each pass advanced roughly 31 tokens on average, indicating a high hit rate and amortized verification cost. In practice, a draft model that is too strong raises per-pass overhead, while one that is too weak lowers the acceptance rate; sampling parameters such as temperature and top-p significantly affect acceptance and need to be tuned to the business scenario.

    6. Profiling Method: Where the 51% Gain from 298 to 450 Comes From

    A disciplined tuning process starts with a reproducible baseline, then attributes gains item by item:

    1. Fix input/output length, sampling parameters, and concurrency, and record baseline throughput (e.g., 298 tok/s).
    2. Use sampling-based profiling to separate three kinds of time: memory-access stalls, kernel launch, and sampling/scheduling.
    3. Change one variable at a time (first operator fusion, then cache compression, then speculative decoding), recording gains and quality changes.
    4. Watch tail latency and stability so averages do not hide jitter.

    Following this path, operator fusion and mixed optimizations contributed the first half of the gains, and speculative decoding delivered the later jump once the hit rate met the target, for a combined improvement of about 51%, stabilizing at around 450 tok/s.

    7. Cross-Platform and Old-Hardware Deployment Advice

    • Interconnect and memory: under PCIe 3.0, minimize host-device round trips; keep weights resident and swap the cache in tiles.
    • Backend abstraction: adapt to different vendors’ accelerators through a unified abstraction layer, avoiding tight coupling between business code and the underlying hardware.
    • Observability: turn throughput, acceptance rate, and cache hit rate into metrics wired into logging and monitoring/alerting to make regressions easy to catch.
    • Delivery: keep the model and conversion tooling decoupled from the inference engine, so it is easy to canary and roll back on container platforms.
    • Cloud augmentation: when local capacity is insufficient, use object storage to distribute weights and container platforms to scale elastically, forming a device-cloud collaboration.

    8. Conclusion

    High throughput on an old platform is no accident; it is the result of combining dedicated kernels, cache compression, and speculative decoding. The takeaway for developers: quantify the bottleneck first, attribute gains with single-variable changes, then amplify the benefit at the algorithm layer. In related engineering practice, Baidu AI Cloud likewise emphasizes driving optimization with observable metrics, helping teams achieve stable local inference performance under constrained hardware and cost limits.