Large Language Model Attention Mechanisms: From MHA and GQA to Million-Token Context in Production
This article examines why a recent open-source large model release drew attention for reverting from low-rank latent attention compression to a multi-query sharing approach augmented with block sparsity and hierarchical caching. It compares MHA, MQA, GQA, and low-rank latent attention in terms of KV cache size and bandwidth, explains why memory capacity, bandwidth, scheduling fairness, and cache reuse become the real bottlenecks at million-token context, and outlines four coupling points between architecture and system design. It closes with a reusable evaluation workflow and operational practices for running long context as a production capability.
1. Why an Architectural “Reversal” Drew Attention
After a new generation of an open-source large model was released, the most discussed change in the community was not the doubling of parameter count. It was the decision to drop the low-rank latent compression scheme used in the previous two generations and return to a more straightforward multi-query sharing design, now layered with block sparsity and hierarchical caching.
The change was striking because the industry had reached a broad consensus: the attention structure of advanced open-source models had converged, and only fine-tuning of numerical precision, normalization placement, optimizers, and data mixtures remained.
Engineering practice points the other way. As context length moves from the hundred-thousand range toward one million tokens, attention stops being just one operator inside a layer. It becomes the central variable that determines memory footprint, memory bandwidth pressure, parallelism partitioning, cache hit rate, and cost per token. At that point, any single-point structural innovation that is not changed together with scheduling, caching, and parallel strategy will have its gains absorbed by system overhead. That is the real meaning of “system-level coupled optimization is harder than single-point innovation.”
2. Aligning the Concepts: MHA, MQA, GQA, and Low-Rank Latent Attention
Understanding this shift requires comparing four common designs in the same frame of reference. Let the sequence length be L, the attention dimension be d, and the number of heads be h.
- Multi-head attention (MHA): each head keeps its own key and value projections. Cache size scales with h, expressiveness is the strongest, but key-value cache bandwidth pressure during inference is high.
- Multi-query attention (MQA): all query heads share one set of keys and values. Cache size drops to roughly 1/h of the original, which is bandwidth friendly, but expressiveness is limited and training stability requires additional techniques.
- Grouped-query attention (GQA): a compromise between the two, splitting heads into groups that share keys and values. It has been the most common engineering compromise over the past two years.
- Low-rank latent attention: keys and values are compressed into a low-dimensional latent space before caching, and a small number of latent vectors reconstruct multi-head information. It saves cache, but adds low-rank reconstruction computation at decode time and implementation complexity.
Schematically, cache size can be written as:
KV_bytes ≈ L * layers * (n_kv_heads * head_dim * 2) * bytes_per_value
The low-rank approach replaces n_kv_heads * head_dim with a smaller latent dimension, while the multi-query approach compresses n_kv_heads directly to 1. Both do the same thing: reduce cache bytes per token. The cost simply lands in different places. One adds a decode operator; the other sacrifices head diversity.
3. The Real Bottleneck at Million-Token Context: Bandwidth and Scheduling, Not Compute
Once L is pushed to the million scale, the structure of the problem changes.
- Memory capacity: cache grows linearly with L, so long requests crowd out batch space and concurrency drops off a cliff.
- Memory bandwidth: during decoding, every generated token requires rereading the entire history cache, so bandwidth rather than compute becomes the ceiling.
- Scheduling fairness: a single very long request occupies cache for a long time, amplifying queueing delay for short requests and requiring chunked scheduling and priority policies.
- Hits and reuse: system prompts, code repository context, and long documents are highly repetitive across multi-turn sessions, so cache reuse rate directly determines cost.
Long-context capability is therefore not a nominal “supported up to” number. It is “how long can be served stably at acceptable latency and cost.” In engineering, this usually means combining chunked attention, sliding window plus global tokens, retrieval-style sparsification, and prefix cache reuse to push complexity from quadratic down to near linear.
4. Four Coupling Points That Architecture and Systems Must Design Together
- Attention structure and parallel partitioning: shared keys and values change the partition boundaries of tensor parallelism and pipeline parallelism, so the structural choice must be evaluated alongside communication volume.
- Caching and batching: the low-rank reconstruction operator changes the operator mix during decoding and affects padding efficiency in continuous batching.
- Sparsity patterns and hardware memory access: block sparsity only pays off when block size aligns with memory access patterns; otherwise it degrades into irregular access.
- Numerics and training stability: more aggressive compression requires better normalization and optimizer support, or long-context extrapolation ability degrades.
A reusable evaluation process looks like this:
1. Fix business corpus and length distribution; measure P50/P95 context length2. Measure cache bytes and theoretical bandwidth ceiling; estimate per-GPU concurrency limit3. Load test with continuous batching; record throughput, time to first token, cost per thousand tokens4. Compare attention and caching strategies by "effective concurrency x average length"5. Base the selection decision on effective throughput, not peak throughput
5. Engineering Practice: Making Long Context an Operable Capability
- Tiered caching: keep frequently reused system context in a resident cache tier, load long document slices on demand, and archive cold data with object storage and logging services.
- Observability: set up monitoring and alerts for cache hit rate, batching wait time, and bandwidth utilization. Hit rate often degrades before latency does.
- Elastic scaling: long-context inference is memory sensitive, so container platforms should scale on both memory and GPU memory metrics rather than request count alone.
- Cost accounting: replace unit price comparison with “effective service cost per million tokens,” including cache discounts, batching efficiency, and failed retries.
- Degradation strategy: automatically split very long requests into retrieval augmentation plus segmented summarization so usable output remains available under capacity pressure.
6. Conclusion
The “return” to a simpler attention design in the new model generation is not a step backward. It reminds developers that the value of architectural innovation is only released when caching, scheduling, parallelism, and the cost model are rewritten at the same time. For consumers, instead of chasing nominal context length, it is better to build an evaluation system centered on effective throughput and cache hit rate. For builders, treating long context as a system capability that requires continuous operation is the path that brings million-token context into production.
