When Caching Is Slower Than Computing: The Hidden Cost of Inference Acceleration

    This article examines a counterintuitive production incident where adding a shared cache to a large-scale MoE model inference service left median latency unchanged but pushed p99 latency from 3.96 seconds to 17.3 seconds. It explains how MoE and low-rank attention compression (MLA) shape storage needs, why shared GPU memory bandwidth and capacity become contended resources, and the four overlooked costs of caching: lookup, write amplification, data movement on hits, and resource crowding. It then outlines how to turn caching into a real speedup through baseline measurement, layout alignment, asynchronous and rate-limited writes, cheap hit detection, tail-latency canarying, and skipping scenarios where caching should not be used.

    1. A Counterintuitive Production Incident

    A team serving inference for a very large Mixture-of-Experts (MoE) model ran into a result that surprised everyone. The service ran on a single node equipped with 8 high-end accelerator cards. To reduce processing time for long-context requests, the engineers added a shared cache layer that stored previously computed attention intermediate results, hoping to reuse them when similar requests arrived and skip redundant computation.

    After deployment, median latency barely improved, while the slowest 1% of requests (p99 latency) jumped from 3.96 seconds to 17.3 seconds, roughly 4.4x. The team’s first reaction was to roll everything back.

    The value of this case is not that “caching is useless.” It reveals a long-underestimated fact: reading from a cache has a cost, and in long-context, high-concurrency inference pipelines that cost is often higher than the computation it is meant to save. When the cache read path is not carefully designed, it is not an accelerator but a tail-latency amplifier.

    2. First, Understand How the Model Consumes GPU Resources

    To understand the root cause, two things must be clear: the model structure determines what data needs to be cached, and the hardware characteristics determine how much it costs to read and write that cache.

    2.1 Storage Characteristics from MoE and Attention Compression

    The service hosts a MoE model with an extremely large parameter count. The core idea of MoE is to let different expert subnetworks handle different types of tokens, scaling the model up without significantly increasing per-token computation. MoE affects computation and routing, but what really determines cache size is the attention mechanism.

    This setup uses a low-rank compression attention scheme (commonly known in the industry as MLA): each token’s key-value information is compressed into a shared low-rank vector. The direct benefit is that regardless of how many attention heads the model has, the intermediate data that must be persisted or kept resident per token is fixed and very small. In this scenario, at FP8 precision with every 256 tokens packed into one block, a single block is about 12.4MB, averaging only about 48.4KB per token.

    This number matters: it makes “caching all historical attention” feasible in terms of capacity, and it tempts engineers into believing that “reading the cache must be cheaper than recomputing.” But small capacity does not mean fast reads.

    2.2 GPU Memory Bandwidth and Capacity Are Shared, Scarce Resources

    In a single-node, 8-card environment, GPU memory capacity, memory bandwidth, inter-card interconnect bandwidth, and compute units are all shared across concurrent requests. Cache reads consume memory bandwidth; cache writes also consume bandwidth while additionally using capacity and crowding out space that could serve the KV working set. As concurrency rises, these resources are contested by both the compute path and the cache path, and tail latency breaks first.

    3. Why the Cache Is Actually Slower: Four Overlooked Costs

    3.1 Hit Determination and Retrieval Overhead

    A shared cache must answer “can this request be reused?” which requires similarity or prefix matching. Approximate retrieval needs extra index structures and vector comparisons; exact prefix matching needs ordered structures and hash verification. This overhead sits on the request critical path and grows non-linearly with cache size.

    3.2 Write Amplification and Concurrency Contention

    Every new request produces writes. Under high concurrency, writes and reads contend for the same bandwidth and lock resources, forming queues. Tail latency is extremely sensitive to queuing: median requests may just miss the congestion window, while the 1% of requests that land inside it get amplified several times over. This is exactly what explains the “unchanged median, exploding p99” phenomenon.

    3.3 The Data Movement Cost After a Hit Is Underestimated

    Even on a hit, the retrieved data must be moved from the cache area into the contiguous address space the computation requires, which may trigger dequantization, reordering, and concatenation. If the cache layout does not match the memory layout the operators expect, the movement cost will swallow all the gains.

    3.4 The Cache Crowds Out Resources That Could Be Used for Computation

    The GPU memory and bandwidth taken by the cache could have gone to the working set of active requests. The result is lower overall throughput, longer queues, and further deterioration of tail latency.

    Schematically, the time for a single request can be written as:

    1. T_total = T_prefill_compute + T_decode_compute
    2. + T_cache_lookup + T_cache_fetch + T_cache_write
    3. + T_queue(resource contention)

    The cache only optimizes part of T_*_compute while adding four new terms: lookup, fetch, write, and queue. When the sum of those four exceeds the computation time saved, the net effect is negative.

    4. Turning the Cache into a Real Speedup

    4.1 Measure First, Then Decide: Establish a Cost Baseline

    Do not enable caching on intuition. First, with caching disabled, collect percentile latency, GPU memory bandwidth usage, cache candidate hit rate, and the data movement time per hit. Use data to answer one question: under your workload, does the saved computation time consistently exceed the read cost?

    4.2 Align the Read Path with the Compute Path

    The memory layout of cache blocks must match what the operators expect, avoiding reordering after a hit; aim for zero-copy or in-place reuse; move dequantization to the write stage rather than the read stage.

    4.3 Make Writes Asynchronous and Rate-Limited

    Move cache writes off the critical path and switch to background batch flushing; cap write bandwidth to guarantee priority for reads and computation. When necessary, set a hard limit on cache capacity and apply an eviction policy to prevent crowding out the working set.

    4.4 Make Hit Determination Cheap and Predictable

    Prefer low-cost prefix- or block-level exact matching, and avoid high-dimensional approximate retrieval on the critical path; move similarity retrieval offline or to a side path, used only for statistics and tuning.

    4.5 Optimize for Tail Latency with Canarying

    Validate with shadow traffic or a small-percentage canary, observing p99/p999 rather than only the mean; set automatic rollback thresholds (for example, roll back if p99 degrades by more than 10%). The observability system should cover three common capabilities: monitoring and alerting, logging, and distributed tracing.

    4.6 Define the Scenarios Where You Should Not Cache

    When request prefix overlap is low, when per-request computation is already very small, or when the system is already in a bandwidth-saturated region, caching is almost certainly a net negative. Identifying these scenarios and skipping the cache outright is the highest-value optimization.

    5. Conclusion

    “Caching is always faster than computing” is common sense that only holds under specific conditions. In a real inference pipeline with very large-scale MoE, compressed attention, and high-concurrency long context, the four costs of reading, writing, movement, and queuing add up enough to multiply p99 latency several times over. The right approach is not to disable caching but to engineer it as a critical path that must be measured, rate-limited, and layout-aligned. Whoever quantifies the hidden costs first can turn the cache from a drag back into a real accelerator.