From MLA to MQA: LLM Attention and the Infrastructure Behind Million-Token Contexts

    A shift from multi-head latent attention (MLA) toward multi-query attention (MQA) highlights how closely LLM architecture is tied to inference infrastructure. This article examines their KV cache trade-offs, the engineering requirements of million-token contexts, and why architecture decisions should prioritize end-to-end efficiency rather than isolated benchmarks.

    1. An Unexpected Shift in Attention Architecture

    Over the past year or so, the open-source large language model ecosystem has moved from isolated breakthroughs to a broader range of architectural approaches. For a time, multi-head latent attention (MLA) appeared to be emerging as a preferred choice for large models. Its ability to compress the key-value (KV) cache during inference attracted adoption by several leading teams.

    That momentum encouraged a view that model architecture was beginning to converge, leaving training strategies, data quality, and post-training alignment as the main areas for incremental improvement.

    Against that backdrop, a newly released generation of open-source models took a different direction: moving away from MLA and returning to the older multi-query attention (MQA) approach. The shift raises an important question: why accept the engineering cost of redesigning attention when MLA already offers an effective solution?

    The answer lies less in attention mechanisms alone than in the relationship between model architecture and the infrastructure used to serve it.

    2. MLA vs. MQA: Two Approaches to Reducing KV Cache Costs

    Understanding the trade-off starts with the KV cache.

    During autoregressive generation, each new token attends to keys and values associated with earlier tokens. Caching those vectors avoids recomputing them, but the cache grows with context length and the number of concurrent requests.

    As contexts expand, KV cache capacity and memory bandwidth become major constraints. In long-context inference, the bottleneck is often not arithmetic throughput alone, but the cost of storing and accessing attention state.

    2.1 MQA: Sharing Keys and Values Across Query Heads

    Multi-query attention takes a straightforward approach: all query heads share a single set of key and value heads.

    For example, compared with conventional multi-head attention using 64 query heads and 64 corresponding KV heads, MQA uses just one KV head. With the same head dimensions and cache precision, this reduces the KV cache to one sixty-fourth of its previous size and substantially lowers the associated memory traffic.

    MQA offers several advantages:

    • A relatively simple attention design.
    • Aggressive KV cache reduction.
    • Potentially substantial improvements in inference throughput.

    The trade-off is reduced representational flexibility. Although query heads remain distinct, they operate on shared key and value representations rather than separate per-head representations. This can limit the diversity of attention patterns and affect model quality, helping explain why MQA did not initially become the default for very large models.

    2.2 MLA: Compressing KV Representations into a Latent Space

    MLA follows a different path. It compresses key and value information into a low-rank latent representation and caches that compressed state during inference. The information needed by individual attention heads can then be derived from it.

    This creates a compromise between the representational flexibility of multiple KV heads and the smaller cache footprint of shared KV representations. Techniques such as matrix absorption allow parts of the computation to be folded into other projections, helping balance quality and inference efficiency without necessarily reconstructing every full KV tensor explicitly.

    The cost is greater systems complexity. The compression path, attention computation, and algebraic transformations used for efficient execution become closely tied to the inference engine.

    As a result, changes to CUDA kernels or communication strategies can have consequences across the implementation rather than remaining isolated optimizations.

    2.3 Why Move Back to MQA?

    Two considerations help explain the shift.

    First, MQA can offer a smaller cache footprint than MLA, depending on their respective dimensions and implementations. At million-token context lengths, even a compressed latent cache can accumulate into a substantial memory requirement. A smaller MQA cache can reduce both capacity pressure and memory traffic, creating room for longer contexts or more concurrent requests on a given machine.

    Second, training can narrow the quality gap associated with shared KV representations. More extensive pretraining and targeted quality alignment can help compensate for reduced architectural flexibility.

    When the quality trade-off is manageable and the serving gains are large, the overall system benefit can outweigh the advantages of MLA’s more elaborate compression scheme.

    This is also why changing attention mechanisms is more than swapping out a model component. Attention operators, fused kernels, parallel execution strategies, and scheduling behavior may all need to be revised and revalidated. Coordinating these changes across the model and serving stack can be harder than improving any one component in isolation.

    3. Million-Token Contexts Require More Than an Architecture Change

    Supporting extremely long contexts is a systems engineering problem. An efficient attention mechanism helps, but practical deployment requires several layers of optimization to work together.

    3.1 Distributed KV Cache Management

    At million-token scale, a KV cache may exceed the memory available on a single accelerator or even a single server, depending on the model and workload.

    Serving such requests can require partitioning and moving cached state across devices or nodes, while managing its validity and lifecycle. Lease-based scheduling and eviction policies are among the mechanisms used to coordinate these resources.

    The challenge is not simply finding enough aggregate memory. The cache must remain accessible in a way that does not make data movement the dominant cost.

    3.2 Sparse and Block-Based Attention

    Not every token needs to interact with every other token in every attention pattern.

    Block-based processing, local attention windows, and hierarchical attention can help keep the computational cost of very long sequences manageable. The goal is to reduce unnecessary interactions while preserving access to information that matters for the task.

    These approaches introduce another trade-off: computational savings must be balanced against the risk of missing relevant information in distant parts of the context.

    3.3 Prefix Caching and Cache Hit Rates

    In production services, many requests share a system prompt or document prefix. Prefix caching reuses the KV state for that shared content across requests instead of recomputing it each time.

    This can reduce time to first token and lower computation costs. Cache hit rate is therefore an important measure of serving efficiency.

    Some services also charge substantially less for cached input tokens. That pricing difference reflects the lower work required when a reusable prefix is already available and can directly affect application costs.

    3.4 Quantization and Tiered Storage

    Low-bit KV cache quantization reduces the amount of memory needed for cached state. Moving less frequently accessed data to lower-cost storage tiers provides another way to control long-context serving costs.

    These techniques depend on supporting infrastructure as well as model-specific code. Storage services, container platforms, monitoring, and alerting all contribute to operating the system reliably.

    The practical value of tiered storage depends on how cached data is accessed and moved: reducing storage cost is useful only if retrieval overhead remains compatible with serving requirements.

    4. Practical Lessons: Choose Architecture for the Workload

    The broader lesson is not that one attention mechanism has replaced another. It is that architecture choices should be evaluated in the context of the intended workload.

    There Is No Universally Best Attention Mechanism

    MLA, MQA, and grouped-query attention (GQA) offer different balances of cache size, representational flexibility, and implementation complexity.

    A short-context, high-concurrency online service may favor a different design from a workload centered on extremely long contexts and sustained throughput. The right choice depends on which resources and service requirements dominate.

    Evaluate End-to-End Gains, Not Isolated Metrics

    A useful architecture comparison should account for:

    • KV cache memory consumption.
    • Memory bandwidth requirements.
    • Scheduling complexity.
    • Inference implementation and maintenance costs.
    • Model quality and serving performance.

    A gain on one benchmark does not necessarily translate into a better production system. An architecture that looks less sophisticated in isolation may still provide a better overall balance when deployed.

    Understand the Cost Structure

    Cached-token discounts and context-length pricing tiers reflect the resource costs of serving requests.

    Understanding the KV cache cost model helps application teams make better design choices. Reusing stable system prompts and avoiding irrelevant context can reduce unnecessary processing and improve the value of prefix caching.

    Application design and inference infrastructure are therefore connected: how prompts are assembled can influence both latency and cost.

    5. Conclusion

    The move from MLA toward MQA illustrates that LLM architecture is far from settled. It also shows that architectural progress is increasingly tied to the systems that make inference practical.

    Future improvements are likely to emerge at the intersection of algorithms and infrastructure rather than from attention design alone. For engineers, understanding how KV caches consume memory, how attention is executed, and how cached state is reused is more valuable than treating any particular architecture as the permanent answer.

    Million-token contexts become practical through the combined effect of model design, cache management, attention optimization, scheduling, and storage—not through a single breakthrough.