The Evolution of LLM Attention: The Return of MQA and the Practice of Million-Token Contexts

    This article examines why a recent open-source large model release drew more attention for reverting from Multi-Head Latent Attention (MLA) to a Multi-Query Attention (MQA) approach than for its parameter scale jump. It explains that the bottleneck of long-context inference lies in memory bandwidth rather than compute, compares MHA, MQA, and MLA, and argues that returning to MQA is a reasonable engineering choice for operator friendliness, hybrid sparse or linear structures, training-inference consistency, and stackable system-level gains. It then outlines four engineering pillars for million-token contexts—cache tiering and reuse, scheduling and batching, parallelism strategies, and observability—along with cost implications of cache-hit pricing, a checklist for evaluating long-context solutions, and a practical end-to-end optimization mindset.

    The Evolution of LLM Attention: The Return of MQA and the Practice of Million-Token Contexts

    1. Introduction: Why an “Architectural Step Back” Drew Attention

    After a recent open-source ultra-large model released its next-generation version, the hottest topic in the technical community was not the jump in parameter count from the 670-billion class to the 1.6-trillion class. It was a step back in the attention mechanism: the model abandoned Multi-Head Latent Attention (MLA), which it had used for two consecutive generations, and moved toward the older idea of Multi-Query Attention (MQA).

    This is worth revisiting because, in the months before the release, the industry had nearly reached a consensus: advanced open-source model architectures had converged on a few options, and only minor refinements remained. The reversal shows that model structure is far from exhausted, and that the real gains may lie in system-level coupled optimization beyond any single-point innovation.

    Rather than reviewing any specific product, this article abstracts the issue into a general engineering question: when context length approaches one million tokens, how do the attention mechanism and the KV cache jointly determine inference cost, and how should the engineering side respond?

    2. Root Cause: The Long-Context Bottleneck Is Memory Bandwidth, Not Compute

    To understand the return of MQA, you first need to see the cost structure of the inference stage.

    During autoregressive decoding, every generated token requires reading the key-value cache (KV Cache) of all historical tokens. This means:

    • Memory usage grows linearly with context length;
    • Every decoding step must read this cache in full, making memory bandwidth the primary constraint;
    • Batch size is squeezed by memory, so throughput cannot scale linearly with concurrency.

    An illustrative capacity estimate (used only to show the order-of-magnitude relationship, not data from any specific implementation):

    1. # Rough estimate of KV cache size: layers x 2(K/V) x heads x head_dim x seq_len x bytes
    2. def kv_bytes(layers, kv_heads, head_dim, seq_len, bytes_per_elem=2):
    3. return layers * 2 * kv_heads * head_dim * seq_len * bytes_per_elem
    4. print(kv_bytes(60, 8, 128, 1_000_000) / 1024**3, "GiB per sequence")

    The conclusion is intuitive: multiply the sequence length by a million, and the cache size scales to the same order of magnitude. What determines long-context usability is “how many bytes must be moved per token,” not theoretical floating-point compute.

    3. The Essential Differences Among Three Attention Schemes

    3.1 Original Multi-Head Attention (MHA)

    Each head holds a complete key-value cache independently. It offers the strongest expressiveness, but cache size is proportional to the number of heads, making it nearly unusable for long contexts.

    3.2 Multi-Query Attention (MQA)

    All query heads share the same key-value, compressing cache size to a fraction of the original by the number of heads and sharply reducing bandwidth pressure during decoding. The cost is reduced expressiveness and harder training stability and convergence, usually requiring finer initialization and learning-rate strategies.

    3.3 Multi-Head Latent Attention (MLA)

    MLA compresses key-values into a low-dimensional latent space, storing only the compressed latent vectors in the cache and projecting them back up during inference. It strikes a compromise between compression ratio and expressiveness, which made it the mainstream choice in the open-source community for a period.

    The trade-offs can be summarized in one sentence: MQA trades structural constraints for bandwidth, MLA trades low-rank projection for balance, and MHA trades redundancy for quality.

    4. Why Returning to MQA Is a Reasonable Choice

    If you only look at cache compression ratio, MLA is more elegant; but the objective function of an engineering system is never single-metric optimality.

    • Operator friendliness: MQA’s key-value layout is regular, making it easier to align with mechanisms such as paged cache, prefix sharing, and speculative decoding, reducing glue-layer overhead;
    • Coordination with sparse/linear hybrid structures: when a model introduces sparse attention or linear attention branches, shared key-values are easier to schedule uniformly;
    • Training-inference consistency: the simpler the structure, the smaller the numerical behavior gap between training and deployment, and the more controllable long-context extrapolation becomes;
    • Stackable system-level gains: saving 30% bandwidth at a single point is less valuable than the end-to-end throughput improvement from jointly saving across “cache layout + scheduling + parallel partitioning.”

    This is what “system-level coupled optimization is harder than single-point innovation” means: the former requires simultaneous changes across four layers—model, operator, scheduling, and deployment—while the gains are closer to real business metrics.

    5. Four Engineering Pillars for Deploying Million-Token Contexts

    5.1 Cache Tiering and Reuse

    Cache stable prefixes such as system prompts, tool definitions, and long documents independently, and share them across requests; place volatile parts at the tail to maximize the prefix hit rate. On the engineering side, you can use a container platform to host stateless inference replicas and place the cache in shared memory or a high-performance storage tier.

    5.2 Scheduling and Batching

    Running long-context requests mixed with short ones causes mutual interference. Requests should be bucketed and queued by context length, combined with continuous batching and chunked prefill, to avoid long requests blocking the queue.

    5.3 Parallelism Strategies

    The context dimension can be partitioned (sequence parallelism), and the cache can be partitioned by layer. When combined with expert parallelism, you need to evaluate communication volume and the boundaries of the split spans to avoid frequent synchronization canceling out bandwidth gains.

    5.4 Observability

    You must monitor cache hit rate, memory read volume per token, queue latency, time to first token, and throughput curves, and use a unified logging service and monitoring/alerting system to locate whether the bottleneck is in the prefill or decoding stage.

    6. Cost Perspective: Why Cache-Hit Pricing Matters

    The billing structure of long-context services differs markedly from traditional per-token billing: the cached portion of the input consumes very little compute, while the uncached portion requires full prefill. As a result, the industry has widely adopted tiered pricing with a “cache-hit discount,” where the discount level adjusts dynamically with supply and utilization.

    Practical advice for users:

    • Put stable long contexts at the front to improve hit rate;
    • Control context bloat; prioritize retrieval and summarization over “stuffing everything in”;
    • Use load-test data rather than unit price for selection, focusing on the cost per unit of effective throughput.

    7. A Selection Checklist: How to Judge Whether a Long-Context Solution Is Mature

    • Does it provide stable time-to-first-token and throughput data at million-token lengths?
    • Is the cache hit rate observable and attributable?
    • Does it support common optimizations such as prefix sharing, chunked prefill, and speculative decoding?
    • Is the attention structure sufficiently adapted to the operator library of the deployment stack?
    • Does it have a fallback strategy: automatic summarization or segmented processing for ultra-long requests?

    8. Conclusion

    From MHA to MLA and then the return to MQA-style thinking, large model architecture is still evolving rapidly, and any judgment that it has “converged” is premature. For developers, a more pragmatic stance is to treat the attention mechanism as one variable of the system and optimize end to end together with cache layout, scheduling strategy, parallelism scheme, and the monitoring system. On platforms such as Baidu AI Cloud, building an observable, elastically scalable inference pipeline with common capabilities such as container platforms, object storage, logging services, and monitoring/alerting is the key path to moving million-token contexts from demo to production.