Breaking the Memory Bottleneck: How Latent Cache Offloading and Prefetching Work
This article explains why memory capacity, not compute, often limits LLM inference throughput during the Decode phase, especially in Prefill-Decode disaggregated architectures. It examines how sparse attention introduces compact Latent Caches that still grow linearly with concurrency, and presents a strategy that decouples the storage path from the compute path by moving the cache to CPU memory and prefetching required slices on demand. The article outlines the core design, feasibility boundaries around bandwidth, latency, and capacity, the ESS (Expanded Sparse Server) system approach, a high-fidelity simulator for pre-implementation validation, simulation results, and practical rollout and risk-mitigation recommendations.
1. The Problem: Why Decode Gets Stuck on Memory
In a Prefill-Decode (PD) disaggregated architecture, the Prefill phase is compute-intensive, while the Decode phase is intensive in memory access and scheduling. As context length grows, every autoregressive step in Decode must read the cached historical state, and the cache size scales linearly with sequence length and the number of concurrent requests. GPU memory capacity is a hard constraint, which leads to a typical situation: compute is not yet saturated, but memory is already exhausted. The batch size cannot grow further, and the throughput curve plateaus earlier than expected.
It is worth emphasizing that increasing batch size is normally the most direct way to raise throughput. A larger batch increases the arithmetic intensity of matrix multiplication operators, spreads weight reads across more requests, and lowers the memory-access cost per token. But when cache usage grows linearly with the batch, this path is blocked. This is the essence of “memory is the main factor limiting throughput”: the issue is not insufficient compute, but an insufficient number of states that can run concurrently.
2. A New Variable: Sparse Attention
A new generation of sparse attention mechanisms significantly reduces computation latency under long contexts by compressing and selecting historical information. But it also changes the shape of the cache: the retained compressed state (which can be understood as a Latent Cache) becomes a critical data dependency on the Decode path. It is more compact than a traditional key-value cache, yet it is still “hot data” accessed per request, per layer, and per step.
This leads to two conclusions. First, compression itself is worthwhile because it reduces the cache size per request. Second, as long as total concurrency rises, the total compressed cache still grows linearly; the bottleneck is only postponed, not eliminated. Therefore, continuing to focus on “compression ratio” yields rapidly diminishing marginal returns, and it is necessary to think along a different dimension.
3. Core Idea: Decoupling the Storage Path from the Compute Path
Our goal is clear: under single-request latency constraints (such as upper bounds on time-to-first-token and per-token latency), migrate the Latent Cache from GPU memory to CPU memory, trading capacity for concurrency and bandwidth for throughput.
The key insight lies in the difference in temporal locality. Each Decode step only needs a small slice of the current request’s cache, while the bulk of the cache stays idle most of the time. This means the main body of the cache can reside in a larger, cheaper memory tier and be moved on demand only when needed. The main points of the approach are:
- Tiered storage: GPU memory holds only a very small active working set and a prefetch buffer, while the rest resides in CPU memory.
- Prefetch engine: based on generation progress and scheduling order, move the required slices for the next step into GPU memory ahead of time.
- Scheduling coordination: the batch scheduler is aware of the transfer queue to avoid “compute waiting on transfer.”
- Overlapped execution: transfers use an independent channel and overlap with operator computation and cross-node communication.
The following illustrative scheduling pseudocode mainly expresses the relationship between “prefetch depth” and “readiness checks”:
def decode_step(batch, cache_store, prefetch):# Issue the transfer for the next step ahead of time; depth is determined by bandwidth and operator latencyprefetch.submit(batch.next_tokens(), depth=PREFETCH_DEPTH)ready = cache_store.wait_until_ready(batch.current_tokens())if not ready:# If not ready, fall back to a smaller batch or yield the time slice to avoid pipeline bubblesbatch = scheduler.shrink_or_yield(batch)return attention_with_latent(batch, cache_store.read(batch.current_tokens()))
4. Feasibility Boundaries and the Upper Limit of Gains
Offloading is not free; the gain comes from “transfer overhead < the additional compute benefit from a larger batch.” Therefore, three boundaries must be quantified:
- Bandwidth boundary: the single transfer volume divided by the available memory bandwidth must be less than the per-step operator latency; otherwise, prefetching cannot keep up with consumption.
- Latency boundary: the queuing and jitter introduced by transfers must fall within the per-token latency budget, which is especially sensitive under long contexts.
- Capacity boundary: memory capacity determines the theoretical maximum concurrency, and headroom must be reserved for the framework runtime and communication buffers.
The conclusion is scenario-dependent: the longer the context and the larger the per-request cache, the higher the relative benefit of offloading; in short-context, high-compute-utilization scenarios, offloading may not be worthwhile. In engineering practice, use “context length × concurrency target” as coordinates to draw a benefit heatmap, then decide on an enablement strategy.
5. System Approach: ESS (Expanded Sparse Server)
ESS is a systematic enhancement component for industrial deployment. Its core is to “decouple” cache storage from the compute nodes, forming an extensible sparse-state service layer:
- Storage decoupling: the cache becomes an independent layer whose capacity can scale horizontally, decoupled from the compute ratio.
- Prefetch pipeline: multi-level buffering plus asynchronous transfer to hide memory access latency.
- Compatibility with existing optimizations: it is orthogonal to mainstream strategies such as multi-token prediction (MTP) and Two-Batch Overlap, and integrates into existing inference systems as an enhancement rather than a rebuild.
- Observability: built-in metrics such as transfer hit rate, queue depth, and bubble ratio support capacity planning.
6. High-Fidelity Simulator: Validate Before Implementing
To reduce the cost of engineering trial and error, we built a high-fidelity simulator that models three types of overhead simultaneously: model operator computation, cross-node communication, and the transfer overhead of offloading and prefetching. It supports batch scanning of configuration combinations (concurrency, context length, prefetch depth, overlap strategy) and provides credible performance estimates and bottleneck identification before the system is deployed, shifting iteration from “change code to validate” to “change parameters to validate.”
7. Simulation Results
Under a 32K context, when the number of multi-token predictions increases from 2 to 4, overall throughput improves by about 123.4%; of this, about 53.1 percentage points come from the increase in the number of predictions itself, and the remaining gain of about 70.2 percentage points is contributed by the offloading and prefetching mechanism. This shows that in the memory-constrained region, the concurrency dividend from capacity expansion can even exceed single-point algorithmic optimization.
In the ultra-long-context test, with the number of predictions at 2 and a context length of 128K, the offloading and prefetching mechanism alone brings about a 123% throughput improvement, confirming the judgment that “the longer the context, the more worthwhile offloading becomes.”
8. Rollout Recommendations and Risk Mitigation
- Profile first: measure the online context length distribution and latency budgets to lock in the benefit range.
- Roll out gradually: use prefetch depth and active working set size as knobs to gradually open up concurrency.
- Fallback strategy: automatically degrade to a small-batch mode when bandwidth or latency goes out of bounds to ensure stability.
- Cost perspective: use “cost per million tokens” rather than throughput alone as the final metric to avoid local optima.
Overall, the essence of the memory bottleneck is a concurrency-capacity bottleneck. By decoupling storage from compute and using prefetching to hide transfer latency, Decode throughput can be pushed to new heights without sacrificing latency constraints, providing a replicable, stackable, and measurable engineering path for long-context inference.
