From MLA to MQA: System-Level Trade-offs in Attention Architectures for Large Language Models
This article examines the evolving attention architectures of large language models, focusing on why some newer models have shifted from Multi-head Latent Attention (MLA) back to Multi-Query Attention (MQA). It explains the system-level trade-offs among MHA, GQA, MQA, and MLA—covering KV cache size, operator library maturity, tensor parallelism, and communication patterns—and discusses the impact on inference costs, cache hit rates, and million-token context deployment.
Large language model (LLM) architectures are still evolving. Over the past year, mainstream open-source teams have invested heavily in the ecosystem, and both model architectures and inference infrastructure have been iterating quickly. This article starts with the attention mechanism and explains why some newer models are giving up MLA in favor of MQA, as well as how that choice affects inference cost and deployment.
1. The Evolution of Attention Mechanisms
Attention is the core of Transformer models. Standard Multi-Head Attention (MHA) keeps separate Key and Value vectors for every query head, which provides strong expressiveness but a large KV cache. Multi-Query Attention (MQA) lets all query heads share the same set of Key and Value vectors, greatly reducing the KV cache, but each head has access to less information. Grouped-Query Attention (GQA) sits in between: query heads are divided into groups, and each group shares one set of KV vectors.
Multi-head Latent Attention (MLA) takes a different approach. It compresses the Key and Value vectors into a smaller latent vector with low-rank projection, caches only that latent vector, and expands it back during computation. This reduces cache pressure while trying to preserve multi-head expressiveness. A few months ago, many researchers expected future models to converge on MLA and its small variations.
However, some newer models have reportedly dropped MLA, which their predecessors used, and switched to MQA. Public materials do not agree on the exact models and reports, and this article cannot verify every detail; readers should rely on the official technical documentation. Even so, this shift shows that architecture preference changes across model sizes and training strategies, and a single optimal solution has not yet emerged.
2. Why System-Level Coupling Is Harder Than a Standalone Innovation
Architecture engineers generally find system-level co-optimization harder than one-off algorithmic changes. A standalone algorithmic improvement—such as switching to a different attention variant—often only works well in small-scale experiments. In real deployment, the algorithm must align with hardware topology, parallel strategies, communication overhead, memory scheduling, and operator libraries.
The following factors commonly affect the choice of attention architecture:
- Cache size. MLA compresses the KV cache, but decoding usually requires an extra projection to expand the latent vector.
- Kernel fusion. MQA matches well with mature operator libraries such as the FlashAttention family. MLA often requires custom kernels, increasing deployment and maintenance cost.
- Tensor parallelism. The fewer KV heads there are, the harder it is to split them across GPUs. MQA has only one shared set of KV vectors, so it usually has to be replicated on every card, which can offset part of the memory saving.
- Communication pattern. The amount of communication in pipeline parallelism and tensor parallelism changes with model structure.
The table below compares the four attention mechanisms using one consistent framework. The conclusions are qualitative; exact values depend on model configuration and framework version.
| Mechanism | KV cache footprint | Extra compute at decode | Operator library maturity | Tensor-parallel splitting difficulty |
|---|---|---|---|---|
| MHA | High | Low | High | Low |
| GQA | Medium | Low | High | Medium |
| MQA | Low | Low | High | High (KV must be replicated) |
| MLA | Low | Higher (requires up-projection) | Medium (often requires custom kernels) | Medium (latent vectors must be replicated) |
This explains why MLA can win on cache size but does not necessarily win on overall throughput. When the model grows to very large parameter counts, the slowest component in the system is amplified, and the architecture choice often has to give way to total throughput and latency.
3. Parameter Scale and Capability
Increasing the parameter count brings capability changes. Related material indicates that newer models have grown from the 670B level to 1.6T parameters. This article does not verify the exact evaluation scope or the method used to measure hallucination rate. It is important to treat parameter count as only an input; capability conclusions depend on the specific benchmark suite, version, and comparison model.
A model at this scale reportedly shows clear improvements on tasks such as mathematical reasoning, code generation, and agent instruction following. Its coding ability still lags behind top closed-source models, but it is in roughly the same tier as mainstream open-source models.
Larger parameters directly raise training and inference costs. Whether the model can be used at scale depends on reducing the unit inference cost while maintaining capability.
4. Inference Cost: How Cache Hits Affect the Bill
Recently, multiple service providers have offered lower prices for inference requests with input cache hits. The mechanism behind this is KV cache reuse. In multi-turn conversation or long-document QA, the prefix content stays unchanged; the server can reuse the KV values already computed for the prefix and avoid repeating computation. Billing price and hit rules vary by provider, so check the corresponding pricing page.
When running your own inference deployment, you can review cost with the following workflow:
- Measure the prefix cache hit rate. Put system prompts and fixed documents at the beginning of the request to improve the hit rate.
- Monitor the time-to-first-token (TTFT) and time-per-output-token (TPOT). After a cache hit, TTFT typically drops, but this should be verified with load tests.
- Design a KV cache swap-in/swap-out policy. If the cache cannot fit in VRAM, it can be offloaded to host memory and then to a lower-cost storage tier, but each swap-in adds latency.
- Schedule GPU instances elastically. Adjust the number of instances based on request peaks and valleys to avoid idle cards being billed continuously.
- Set up monitoring and alerts. Focus on memory utilization, cache eviction rate, queue length, and error rate.
Cloud platforms generally offer GPU containers, in-memory caches, and object storage as basic resources. Choose them based on resource specifications, network bandwidth, and cost models.
5. Infrastructure Challenges on the Way to a Million-Token Context
As the context window moves toward a million tokens, pressure on infrastructure increases. The KV cache size can be roughly estimated as:
KV cache bytes ≈ 2 × number of layers × number of KV heads × head dimension × sequence length × bytes per element
Assume a model with 60 layers, 8 KV heads, a head dimension of 128, and FP16 precision (2 bytes per element). For a sequence of 1 million tokens, the KV cache of a single sequence is about 246 GB. This is only an example, but it shows that long contexts require fewer KV heads or a compressed cache.
On the inference framework side, PagedAttention splits the KV cache into fixed-size blocks and allocates them on demand, which can reduce memory fragmentation caused by variable-length sequences. Frameworks such as vLLM already support this mechanism, depending on the version.
When deploying across nodes, prefilling long sequences and transferring KV data can consume a lot of network bandwidth. RDMA networks can lower latency, and distributed file systems can hold cold data. The two need to be designed together; otherwise data transfer becomes the bottleneck.
Here are several common questions developers ask:
What is the first bottleneck for a million-token context? Usually VRAM capacity, followed by memory bandwidth for attention computation, then cross-node communication.
What are the prerequisites for PagedAttention? The framework must support it, and the target model structure and hardware backend must be compatible.
What to watch when deploying RDMA? Confirm the NIC and driver version, topology affinity, and congestion control configuration.
Conclusion
Architecture choices depend on model size, hardware, and framework versions; there is no universal optimal solution. Developers should evaluate attention mechanisms, parallel strategies, and cache hit rates together to determine whether inference cost and long-context deployment are feasible.
