LLM Architecture Evolution: From Attention Optimization to Mixture of Experts
This article traces the shift in large language model design from raw parameter scale toward inference efficiency, and explains three general techniques behind that shift: Multi-head Latent Attention (MLA) for compressing the KV cache, Mixture of Experts (MoE) for adding capacity through sparse activation, and small, frequent version iterations as a practical model engineering rhythm. It covers where the memory bottleneck in autoregressive decoding comes from, the trade-offs of low-rank compression versus head pruning, the load balancing, communication, and deployment costs of sparse experts, and how to turn architectural advantages into measurable cost advantages through baseline measurement, context layering, and cost observability. Code snippets for estimating KV cache size and an iteration loop are included.
1. Introduction: Efficiency Has Become the Main Axis of LLM Competition
Over the past two years, attention in the LLM space has shifted noticeably: away from “is the parameter count large enough” and toward “how much usable intelligence can a given unit of compute produce.” For developers and enterprise users, this shift shows up directly on the bill. Inference cost, memory footprint, concurrent throughput, and time to first token often determine whether an application can ship and stay in operation far more than leaderboard scores do.
The evolution described in the source material is representative. When a certain model was released in May 2024, the research team introduced Multi-head Latent Attention (MLA), which substantially reduced memory usage and cost during inference, and established a Mixture of Experts (MoE) technical direction. A follow-up version released that December laid the foundation for overall performance with an efficient MoE architecture, and subsequent minor releases continued to refine the experience and agent capabilities.
Setting aside the specific product attributes, this article abstracts that progression into three general technical questions: how to relieve the memory bottleneck of the attention mechanism, what the benefits and costs of a sparse expert architecture are, and why an incremental, small-step iteration approach suits model engineering.
2. Where the Memory Bottleneck Comes From: A Structural Problem in Attention Caching
Every round of autoregressive decoding rereads the historical context. To avoid recomputation, engineering practice generally relies on a key-value cache (KV Cache). The problem is that the cache grows linearly with “number of layers × number of attention heads × sequence length × data type width.” When the context expands from a few thousand tokens to hundreds of thousands, the cache itself can exceed the model weights, becoming the primary consumer of memory and directly compressing the number of requests that can run concurrently.
A rough formula helps convey the magnitude (it expresses only the trend, not the parameters of any specific implementation):
# Rough estimate of KV Cache memory usage (in bytes)def kv_cache_bytes(layers, kv_heads, head_dim, seq_len, batch, bytes_per_elem=2):# 2 accounts for the two caches, K and Vreturn 2 * layers * kv_heads * head_dim * seq_len * batch * bytes_per_elemprint(kv_cache_bytes(layers=32, kv_heads=8, head_dim=128,seq_len=32768, batch=8) / 1024**3, "GiB")
The conclusion is straightforward: sequence length and batch size are multiplicative factors, so any method that compresses “how much information must be stored per token per layer” yields proportional gains.
3. The Core Idea of Multi-head Latent Attention: Low-Rank Compression, Not Crude Pruning
MLA does not simply reduce the number of heads or truncate the context. Instead, it projects keys and values into a low-dimensional latent space, caches only that compressed latent representation, and up-projects it back into per-head keys and values when needed. The engineering implications are threefold:
- Memory and bandwidth drop together. What is cached is a low-dimensional vector, so read cost falls accordingly. Since the decoding stage is often bandwidth-bound rather than compute-bound, throughput gains typically exceed the theoretical estimate.
- Representational capacity is preserved. Low-rank compression retains the shared information structure across heads, making it friendlier to tasks such as long-text retrieval and multi-hop reasoning than directly pruning heads.
- It is orthogonal to quantization. The latent cache can still be combined with low-precision storage, so the two sets of gains multiply rather than exclude each other.
In practice, implementation complexity deserves attention: compression and restoration introduce additional operators, and if the framework and operator libraries lack support, you can end up with “memory went down but latency did not.” When evaluating options, therefore, treat “does the inference framework natively support this attention form” as a hard checklist item.
4. The Mixture of Experts Route: Trading Sparse Activation for Capacity
The basic MoE structure replaces the feed-forward layer with multiple parallel expert subnetworks, and a routing (gating) network selects a small number of experts to participate in the computation for each token. The benefit is that “total parameter count can be very large while per-token computation stays controlled.” The costs concentrate in three areas:
- Load imbalance. A few popular experts are over-selected, leaving some devices idle and reducing overall throughput. An auxiliary balancing loss or a capacity factor is usually needed to constrain this.
- Communication overhead. When experts sit on different devices, the all-to-all communication introduced by routing easily becomes the bottleneck, especially in cross-node deployments.
- Memory and deployment barriers. A large total parameter count means higher weight loading and storage costs, and quantization, cache reuse, and parallelism strategies need more careful tuning.
The engineering recommendation is to treat MoE and attention optimization as a combined approach: the former raises “effective capacity per FLOP,” while the latter lowers “memory and bandwidth per token.” Together they determine the usable concurrency at a given unit cost.
5. Minor Version Iteration: A Sensible Rhythm for Model Engineering
The “continuous minor version refinement” mentioned in the material reflects a pragmatic engineering rhythm. Model capability is not determined by pretraining alone. Post-training work such as instruction fine-tuning, preference alignment, long-context extension, tool calling, and constraints on agent behavior can all noticeably improve the experience without rebuilding the base model. A reasonable iteration framework includes:
- Reproducible evaluation: fix the evaluation set and inference parameters, and record four categories of metrics — quality, latency, memory, and cost — to avoid “upgrading by feel.”
- Gradual rollout and rollback: validate a new version on a small traffic share first, and keep a one-click rollback path.
- Dedicated agent capability validation: multi-step task success rate, tool-call parameter correctness, and exception recovery should be measured separately from single-turn question answering.
Iteration loop: requirements/failure samples -> data construction -> post-training -> offline evaluation-> small-traffic rollout -> online metric monitoring -> rollback or full release
6. Implementation Advice: Turning Architectural Advantages into Cost Advantages
- Measure the baseline first. Use real business samples to profile the distribution of input and output lengths, then estimate cache and concurrency limits from that, rather than applying generic parameters.
- Layer the context. Put long-term knowledge in retrieval or object storage, and inject only the necessary fragments into the context, cutting cache growth at the source.
- Add supporting services. Use a container platform for elastic scaling, logging services, and monitoring alerts to locate long-tail latency, and use a message queue to smooth out traffic peaks and troughs.
- Make cost observable. Tag each request category and account for it along two dimensions, tokens and GPU time, to identify the scenarios that genuinely consume the most.
7. Conclusion
From low-rank compression of the attention cache, to capacity expansion through sparse experts, to experience refinement through frequent minor versions, this evolution points in one common direction: efficiency first. For developers, understanding the memory, bandwidth, and communication constraints behind these mechanisms is more valuable than memorizing any single metric. When deploying on platforms such as Baidu AI Cloud, evaluating architectural features together with engineering support is what turns the technical dividend into a sustainable, operable cost advantage.
