When Caching Becomes Slower Than Computation in LLM Inference
In large language model (LLM) online inference, hitting a cache is conventionally assumed to be faster and more cost-effective than recomputing. However, in large-scale Mixture of Experts (MoE) deployments, this assumption often breaks down. This article explores why remote shared caching can cause severe tail latency issues, how synchronous multi-GPU pipelines amplify these delays, and actionable engineering strategies to transform a lagging cache back into a high-performance accelerator.
In large language model (LLM) online inference, there is a long-standing assumption: always hit the cache if possible. The logic of “compute once, store, and read directly next time” seems universally cost-effective. This is especially true for long contexts—attention intermediate results are large and expensive to recompute. Adding a shared cache layer appears to save compute and return similar requests faster.
However, in real-world, ultra-large-scale Mixture of Experts (MoE) serving, this assumption gets severely tested. A typical scenario: after enabling a remote shared cache, the median latency barely moves, but the slowest 1% of requests degrade from a few seconds to tens of seconds, forcing a complete feature rollback. The issue is not a flawed cache algorithm, but rather that reading the cache itself incurs a cost. In a highly synchronous multi-GPU pipeline, this cost is amplified into a tail latency disaster.
Let’s break down the system to understand where the cache slows down, why this is underestimated, and how to restructure it for genuine performance gains.
How Inference Nodes Interlock
MoE models use sparse activation to expand capacity: a single forward pass only activates a subset of experts, meaning compute grows slower than parameters. On the attention side, using compression designs like Multi-head Latent Attention (MLA), the key-value (KV) for each token no longer expands linearly with the number of heads. Instead, it is compressed into a shared low-rank representation. Engineers often group a fixed number of tokens into a block, compressing a single block to the tens of megabytes level, averaging just a few tens of kilobytes per token. This makes storing attention intermediate results in a cache viable from a capacity standpoint.
Long-text prefilling still consumes significant VRAM and compute. A common approach is context parallel prefilling: splitting the long sequence into segments, distributing them across multiple accelerators on the same node, and broadcasting the results via high-speed interconnects so every GPU holds the complete context. The compute processes on a node interlock like gears—every step requires collective synchronization. If even one rank gets stuck reading from a remote cache, queuing, or retrying, the other ranks can only spin idly. Tail latency thus becomes not “one GPU slows down a bit,” but “the entire group slows down together.”
Caching is typically implemented in two tiers:
- Local tier (L1): Resides in local host memory or high-speed media close to the accelerator. It offers low latency and limited capacity, serving hot data for the local node.
- Remote tier (L2): Resides in a cluster-shared key-value store with large capacity, shared across multiple inference engines like a public library.
The bottleneck almost always occurs at L2. Local accounting works fine; but when all stores’ transactions must be written to a single ledger with limited teller windows, a long queue forms at the accounting desk during peak hours. The read path is the same: hit rate statistics may look great, but queuing and network round-trips drag down the unluckiest requests.
Why “Reading is Slower Than Computing” is Systematically Underestimated
First, cost models rely on averages, but systems fail at synchronization points. Design documents often state “a single remote get only takes a few hundred microseconds.” This might hold true for a single GPU, short sequence, and zero concurrency. But when eight GPUs march in lockstep, pulling multiple blocks during the prefill stage while sharing the same storage cluster across the entire inference traffic, the tail turns into millisecond- to second-level queuing, retries, and timeouts. Synchronization barriers replicate these spikes identically to every rank.
Second, a cache hit does not equal saved compute. MLA reduces the block size, but long contexts mean many blocks. A single request might sequentially read dozens or hundreds of blocks. While a single read is cheap, the cumulative tail latency, connection occupancy, serialization/deserialization, and precision conversion (e.g., storing in low precision and restoring it) create substantial overhead. If blocks are misaligned, fail checksums, or have version mismatches, it falls back to recomputation—meaning you pay for both the read and the compute.
Third, write amplification and read amplification coexist. To benefit “the next similar request,” prefill results must be written to the shared tier. Multiple GPUs flushing the same hot key or prefix simultaneously creates hotspots on the storage side. On the read side, a naive “check L2 then L1” strategy will overwhelm the shared tier during cold starts or traffic bursts. The median might still look good (since many requests never reach L2), but p99 latency specifically punishes those requests “expecting to reuse a long prefix.”
Fourth, scheduling and cache semantics are misaligned. Online systems often batch requests based on fairness, priority, or continuous batching. Cache-friendly ordering (grouping identical prefixes) does not align with latency-friendly ordering (short requests first). After enabling shared caching, if the scheduler still queues based on original policies, hits become random. Unhit long requests queue for storage and then queue for synchronization, doubly amplifying the tail.
The following table illustrates the magnitude (illustrative, not actual product metrics):
| Phase | How It’s Often Estimated in Design | Actual Behavior Under Multi-GPU Sync |
|---|---|---|
| Local (L1) Hit | Microsecond copy | Still constrained by PCIe/memory bandwidth and lock contention |
| Remote (L2) Hit | “A single RTT” | Queuing + sequential blocks + hotspots |
| Miss Fallback | Equals no cache enabled | Full recompute after read timeout, worse than never enabling cache |
| Intra-node Sync | Negligible | The slowest rank determines the entire step’s duration |
Transforming a Lagging Cache into a Real Accelerator
The goal of the revamp isn’t a better hit-rate poster, but rather: any single read, in the worst case, must not stall the synchronization step; the expected benefit of a read must reliably exceed recomputation.
1. Give the read path a strict time budget.
Set a hard timeout for L2. If it times out, immediately fall back to local recomputation and forbid dead-waiting at the barrier. The timeout value should be smaller than a fraction of the recomputation time for a single block and adapt to block size and parallelism. Timeouts should be tracked as an independent metric to avoid situations where it “looks like a hit but is actually retrying.”
2. Change the shared tier from “synchronous blocking reads” to “asynchronous filling.”
The critical path of a request should only touch L1 and compute. When L2 hits, use a bypass to push data into L1 for use by subsequent tokens or requests, rather than stalling the current prefill at the remote layer. For extremely long prefixes, you can synchronously wait for only the “first few blocks,” computing and filling the rest concurrently to reduce barrier counts.
3. Use prefix and block-aligned cache keys; reject fragmented hits.
Keys should include the model version, precision, parallel sharding method, positional encoding, and block boundaries. A “partial hit” from an incorrect sharding should be treated as a miss rather than read back and stitched together—stitching is often slower than recomputing and prone to silent errors. Aligning block size with context parallelism sharding reduces cross-rank inconsistencies.
4. Keep L1 hot; L2 should only handle true cross-instance reuse.
L1 should use prefix-aware eviction (prioritizing long common prefixes) and implement read-only sharing or broadcasting among multiple ranks within a node to avoid eight copies exhausting memory. L2 is suitable for stable cross-session, cross-instance prefixes (like a shared knowledge base or system prompt), not forcing the upload of all one-off conversations. Writes should use merging and rate limiting to eliminate single-key hotspots.
5. Scheduling must be cache-aware but prioritize tail isolation.
Continuous batching can perform limited aggregation on identical prefixes to improve L1 hit rates. Simultaneously, provide a separate queue and concurrency limit for “remote-dependent requests” to prevent them from saturating storage connections. Priority-wise, short and compute-only requests should not be dragged down by long prefix fetches. This is tail latency governance, not just a caching strategy.
6. Use the right metrics instead of comforting yourself with hit rates.
You should monitor simultaneously: L1/L2 hit rates, single-block read latency distribution, blocks per request, timeout fallback ratio, sync stall time caused by waiting for cache, and p50/p95/p99 end-to-end latency. If p99 degrades while hit rate increases, treat it as an incident, not a successful optimization. Capacity planning should be based on peak concurrent block reads, not average daily QPS.
When deploying in the cloud, L1 can use high-performance memory and local disks, while L2 uses managed key-value or object storage-like services for cold prefixes. Observability relies on unified logging, monitoring, and alerting. Standard cloud capabilities are sufficient; the key is to factor network RTT, connection counts, hotspot shards, and cross-AZ latency into the time budget, rather than assuming “shared storage equals free memory.”
Actionable Engineering Principles
- A cache is another pipeline, not a zero-cost lookup. Any cross-process or cross-node read requires timeouts, circuit breakers, and fallbacks.
- Synchronization width determines tail latency. The more ranks in context parallelism, the less you can afford uncontrollable I/O within a barrier.
- Smaller size doesn’t mean fewer operations. Compressing attention reduces bytes per block but may increase block count. Optimization must start from “total read latency per request.”
- Better to miss than to hit slowly. A bad L2 hit (queuing, retrying, inconsistent) hurts p99 more than a miss.
- Stabilize the fallback path before improving the hit rate. The fallback must be a complete, correct, and predictably fast recomputation, not a half-read, half-compute hybrid.
Illustrative pseudo-code (logic representation, not a specific API):
function load_block(key, deadline):b = L1.get(key)if b: return bif now() + l2_slo > deadline:return compute_block() # Avoid touching remote storageb = L2.get_with_timeout(key, l2_slo)if b:L1.put(key, b)return bb = compute_block()enqueue_async_write_L2(key, b) # Do not block the barrierreturn b
Conclusion
“Caching is always faster than computing” only holds true under single-machine, low-concurrency, and zero-synchronization assumptions. Ultra-large-scale MoE inference makes attention compressible enough to cache, but it also binds multi-GPU prefilling into a set of precision gears. At this scale, every queue at the shared layer translates to a machine-wide halt. By explicitly modeling read costs, moving remote reads off the critical path, and protecting synchronization steps with timeouts, caching shifts from a “dragging feature” back to an accelerator for long contexts. For R&D and platform teams, the real metric to optimize isn’t the hit rate curve, but whether the slowest read will force all GPUs to wait together.
