When the Cache Is Slower Than the Compute: The Storage Revolution Behind Attention Mechanisms

    This article explains why data movement, rather than raw compute, often becomes the bottleneck in long-context LLM inference, and how Multi-head Latent Attention (MLA) addresses it. Instead of storing a full key and value tensor for every attention head, MLA compresses each token's key-value information into a shared low-rank latent vector and projects it back on demand. The result is a fixed, small per-token cache footprint that is decoupled from the number of heads—about 48.4KB per token under an FP8, 256-token block setup from a public paper. The article covers the memory wall, the core idea behind MLA, capacity planning, engineering trade-offs, a practical deployment checklist, and common misconceptions.

    In long-context inference, an often-overlooked fact is that moving intermediate results in and out of high-speed cache can sometimes take longer than performing the actual matrix multiplications. One common class of attention designs—Multi-head Latent Attention (MLA)—was proposed specifically to address this bottleneck. Instead of storing a complete key (K) and value (V) tensor for every attention head, MLA compresses each token’s key-value information into a shared low-rank latent vector and projects it back on demand during inference. The direct result is that the cache data that must remain resident per token is fixed and small, regardless of how many attention heads the model is configured with. For example, in the setup from a publicly available paper, under FP8 precision, every 256 tokens are packed into a “block” of roughly 12.4MB, which averages out to only about 48.4KB per token. This article aims to explain this phenomenon thoroughly: why the cache becomes slow, why compression helps, and how to evaluate and implement it in engineering practice.

    1. Overturning the Conventional Wisdom: The Memory Wall and the Real Cost of Moving Data

    The conventional view is that the bottleneck in model inference is compute: the larger the parameter count and the more operators involved, the longer it takes. But in long-context, high-concurrency serving scenarios, the bottleneck often shifts upstream to data movement. GPU compute has long grown faster than memory bandwidth, creating what is known as the “memory wall.” During the attention decoding stage, every generated token requires reading through the entire historical key-value cache, and the read volume grows linearly with context length. Meanwhile, the vector size actually involved in computation at each step is very small, resulting in extremely low arithmetic intensity (the number of floating-point operations per byte of data). At this point, time is mainly spent “waiting for data to arrive,” while compute units sit largely idle. This is the origin of “the cache being slower than the compute,” and it is the fundamental reason why KV cache compression has become a core topic.

    2. The Core Idea of MLA: From “Multi-head Storage” to “Shared Low-rank”

    The conventional implementation of multi-head attention keeps independent keys and values for each head. The cache size equals layers × heads × head dimension × sequence length × bytes per precision value, expanding linearly with the number of heads. MLA takes a different approach: it projects each token’s key-value information into a low-dimensional latent space and stores only this shared vector. When attention computation is needed, an up-projection matrix reconstructs the keys and values for each head. Mathematically, this is equivalent to approximating the original high-dimensional key-value matrix with a low-rank decomposition, substantially reducing storage while keeping information loss controllable. Its key property is “decoupling from the number of heads”: adding attention heads no longer increases the cache proportionally, but only adds a small amount of projection parameters and computation.

    Illustrative pseudocode (expressing the idea only, not a specific implementation):

    1. # Write phase: cache only the low-rank latent vector
    2. latent = down_proj(x) # compress token x into a shared latent vector
    3. cache.append(latent) # fixed overhead per token
    4. # Read phase: up-project on demand to reconstruct each head's K/V
    5. K = up_proj_k(latent) # reconstruct multi-head keys
    6. V = up_proj_v(latent) # reconstruct multi-head values
    7. scores = softmax(Q @ K.T / sqrt(d))
    8. out = scores @ V

    3. The Quantified Ledger: What 48.4KB per Token Means

    In the paper’s setup, under FP8, every 256 tokens form a block of about 12.4MB, which converts to roughly 48.4KB per token. The value of this number lies in its “predictability”: cache usage is independent of the number of heads, linear with context length, and directly tied to the precision choice. For capacity planning, you can quickly estimate memory requirements using “context length × bytes per token × concurrency,” and use that to determine the concurrency and maximum context a single card can support. Compared with traditional multi-head caches that often cost hundreds of KB or even MB per token, the compressed ledger turns long-context serving from a “luxury” into an “operable resource.”

    4. Re-examining the Engineering Benefits and Costs

    There are three benefits. First, bandwidth pressure drops: fewer bytes moved during decoding directly translate into higher throughput and lower latency. Second, memory usage drops: the same hardware can support longer contexts and higher concurrency. Third, the cache is decoupled from the number of heads, giving more freedom in tuning model architecture. The costs must also be faced squarely: up-projection introduces extra computation, and a poor implementation can offset the bandwidth gains; low-rank compression entails information loss, so the structure must be incorporated during training rather than retrofitted afterward; blocking and reconstruction logic increase kernel complexity, placing higher demands on operator implementation and scheduling. Therefore, MLA is not a “free lunch,” but a rebalancing that shifts cost from the storage side to the compute and engineering sides.

    5. A Practical Deployment Checklist

    1) Start with an arithmetic intensity assessment: measure the bytes read and floating-point operations per step during decoding to confirm whether you are in a bandwidth-bound regime. 2) Build a capacity planning table: list the memory budget for your target context length and concurrency, leaving room for fragmentation and a safety margin. 3) Define a precision strategy: weigh quality against cost between FP8 and higher precision, keeping higher precision for sensitive layers. 4) Manage blocking: organize the cache at a fixed block granularity to make paging, swapping out, and reuse easier. 5) Optimize operators and scheduling: prioritize fusing up-projection with attention to reduce round trips of intermediate tensors. 6) Ensure observability: use monitoring, alerting, and logging services to track cache hit rate, bytes moved per step, and latency percentiles. 7) Enable elastic scaling: combine container platforms and message queues for request queuing and scaling, preventing long-context requests from crowding out short ones.

    6. Common Misconceptions

    Misconception one: compression necessarily degrades quality—if the low-rank structure is introduced during training, the quality impact is usually controllable. Misconception two: looking only at memory and not bandwidth—the throughput bottleneck is often in data movement, not capacity. Misconception three: ignoring block granularity—blocks that are too large waste space, while blocks that are too small increase metadata and scheduling overhead. Misconception four: treating the cache as a pure memory problem—it simultaneously involves operators, scheduling, and service orchestration.

    Conclusion

    “The cache is slower than the compute” reminds us that inference optimization must return to data flow itself. MLA replaces multi-head keys and values with a shared low-rank vector, compressing the per-token cache to a fixed and very small magnitude and rearranging the cost structure of long context. For developers, the real takeaway is not memorizing the number 48.4KB, but mastering a method: first assess arithmetic intensity, then set precision and block granularity, and finally use observability and an elastic architecture to stabilize the gains. With the general-purpose capabilities of cloud platforms such as Baidu AI Cloud (for example, object storage, container platforms, and monitoring and alerting), this method more easily moves from paper to production.