Why LLM Inference Costs Can Drop Fourfold: The Role of KV Cache Reuse

    This article explains why large language model inference costs can fall to a quarter of their previous level, focusing on the engineering mechanism behind the price change rather than the price itself. It covers why autoregressive generation is expensive, how KV Cache works, the memory model that makes it a bottleneck, where high cache hit rates come from, and how to measure performance with observable metrics. Developers will learn practical ways to structure prompts and manage concurrency so that cost savings are sustainable and measurable.

    1. Introduction: The Real Variables Behind the Price Drop

    When an LLM inference service announces a “permanent price cut to one quarter,” the discussion usually stays focused on the price itself. From an engineering perspective, however, price is only the outcome. The real variable is how far the compute and GPU memory cost per token have been compressed. The most direct factor here is the reuse efficiency of the key-value cache (KV Cache). When a segment of context can be hit repeatedly from cache, redundant computation is eliminated, server capacity rises significantly, and only then is there room for costs to fall. This article does not target any specific product; it discusses only this general technical mechanism and its engineering implications.

    2. Why Autoregressive Generation Is Expensive

    Text generation is an autoregressive process: each step produces a single token, which is appended back to the sequence to continue generation.

    1. step1: input [today weather] -> output is
    2. step2: input [today weather is] -> output good
    3. step3: input [today weather is good] -> output ...

    In the attention mechanism, every token produces three vectors: Q, K, and V. The problem is that step2 needs the K and V of the first three tokens, which were already computed in step1 and are exactly the same. Without caching, generating each new token requires recomputing the entire history, so the computation accumulates linearly with sequence length. This is especially noticeable in long-context scenarios.

    3. How KV Cache Works and Its Memory Model

    The approach is straightforward: after each token is computed, its K and V are written to GPU memory. Subsequent steps compute only the Q, K, and V of the new token, use the new Q with all cached K to derive attention scores, and then apply weighting over the cached V. Per-step computation drops from “processing the whole sequence” to “processing one token.”

    The cost is GPU memory. A common estimation formula is:

    1. KV memory = 2 × layers × heads × head_dim × sequence_length × bytes_per_value

    For a 32-layer, 32-head model with a head dimension of 128 in FP16, a single token in a single layer takes 2 × 32 × 128 × 2 = 16KB. At a length of 4096, one request is about 2GB, and 10 concurrent requests reach roughly 20GB. As this shows, in long-text and high-concurrency settings, the cache can consume more memory than the weights themselves and become the true bottleneck.

    4. Where High Hit Rates Come From

    A high hit rate is not magic; it is the result of three engineering capabilities working together:

    • Prefix consistency: fixed prefixes such as system prompts, tool definitions, and a few examples are reused stably, with clear hit boundaries.
    • Cache tiering and scheduling: GPU memory, host memory, and external storage form a hierarchy, and eviction policies combined with batch scheduling keep hot data in the nearest tier.
    • Structured input habits: placing volatile content later and fixed content earlier can significantly increase the length of the reusable prefix.

    It is worth emphasizing that the hit rate depends heavily on the calling pattern. If the prefix differs on every request, the hit rate will naturally be low. Only when long documents and long specifications are placed in stable positions do the gains materialize.

    5. How to Assess “What Level You Are At”

    It is better to rely on observable metrics than on intuition:

    1. Hit rate: cached tokens / total input tokens, measured separately per business scenario.
    2. Time to first token and per-token latency: the former reflects prefill pressure, the latter reflects decode pressure.
    3. Cost per token: account for GPU memory usage, concurrency, and average sequence length together.

    Illustrative measurement logic:

    1. hit = 0
    2. total = 0
    3. for req in requests:
    4. prefix_len = common_prefix_len(req.prompt, cache_index)
    5. hit += prefix_len
    6. total += len(req.prompt)
    7. print(hit / total)

    6. Engineering Practice Recommendations

    • Keep system prompts and tool descriptions fixed, with the lower change frequency the better;
    • Place stable sections at the front of long contexts, and move volatile fields such as timestamps and random IDs to the end;
    • Set concurrency and maximum context length reasonably to avoid cache contention that reduces overall throughput;
    • Build dashboards for hit rate and latency, and quantify cost savings in business terms.

    7. Conclusion

    A fourfold reduction in inference cost is essentially an engineering outcome of cache reuse, scheduling optimization, and input organization working together, not a single pricing strategy. By understanding the memory model of KV Cache and the conditions for cache hits, developers can capture these gains at the architecture design stage and make cost optimization sustainable and measurable.