Understanding Sparse LLMs: A Technical Breakdown of MoE and MLA Architectures
This article explains why parameter count is no longer the only metric that matters in large language model design, and how two key architectural ideas address the resulting constraints. It covers how Mixture of Experts (MoE) decouples knowledge capacity from per-token compute, the engineering challenges of expert routing, and how Multi-head Latent Attention (MLA) compresses the KV cache for long-context inference. It also reviews pretraining and alignment data choices, the cost implications of low-price APIs, and practical guidance on model selection, private deployment, observability, and version management. Readers will gain a clear, implementation-oriented understanding of how sparse architectures extend the usable limits of hundred-billion-parameter models.
1. Why Parameter Count Is No Longer the Only Metric
For the past few years, the main axis of competition in large models was the simultaneous expansion of parameter count and corpus size. But once models entered the hundred-billion-parameter range, two practical constraints began to dominate engineering decisions: the compute budget for training and inference, and the limits of memory capacity and memory bandwidth. In a dense architecture, every layer applies the same matrix operations to all inputs, so parameter growth pushes up compute and memory usage almost linearly. This creates a clear tension between “bigger” and “actually usable.”
The sparse approach answers this by decoupling knowledge capacity from per-token compute: make the model large enough to hold more knowledge, while letting each token pass through only a small fraction of the parameters. The second generation of open-source MoE models is a representative implementation of this idea—roughly 236 billion total parameters, with only about 21 billion activated per token, an activation ratio below one tenth. Understanding this ratio is the prerequisite for understanding every performance and cost conclusion that follows.
2. Mixture of Experts: Splitting Dense Layers into Routable Subnetworks
2.1 Basic Structure
The core idea of MoE (Mixture of Experts) is to replace the feed-forward network (FFN) in a Transformer with several parallel “expert” subnetworks, and to use a gating network (Router) to select a few experts for each token. Mathematically, it can be written as:
# Illustrative code: Top-K expert routing (not a specific product API)def moe_layer(x, experts, gate, k=2):scores = gate(x) # [batch, seq, num_experts]topk_val, topk_idx = scores.topk(k, dim=-1)weights = softmax(topk_val, dim=-1)out = 0for i in range(k):idx = topk_idx[..., i]out = out + weights[..., i:i+1] * experts[idx](x)return out
The key point: parameter count is determined by the number of experts, while compute is determined by the number of activated experts. This lets model capacity and inference cost be tuned independently.
2.2 Engineering Challenges and Common Countermeasures
Fine-grained expert splitting is a common way to improve the capacity-to-compute ratio: make experts smaller and more numerous, and increase the number of experts activated per token, so you get stronger compositional expressiveness at the same activated-parameter budget. The problems that come with this are concentrated:
- Load imbalance: a few popular experts are over-selected while the rest sit nearly idle. The common industry practice is to add an auxiliary load-balancing loss, together with expert capacity limits and overflow handling.
- Communication overhead: when experts live on different devices, routing results trigger cross-device data exchange, and the communication volume can exceed the compute itself. This requires overlapping compute with communication and choosing parallelization dimensions sensibly.
- Training stability: drift in the scale of gating logits causes routing oscillation. Common mitigations include normalizing routing scores and adding a z-loss constraint.
3. Latent Attention: The Key Design for Compressing the KV Cache
In long-context scenarios, the real bottleneck is often not parameter count but the KV cache during inference. Cache size scales with the number of layers, the number of attention heads, the head dimension, and the sequence length, so a 128K context makes memory usage balloon quickly.
MLA (Multi-head Latent Attention) takes the approach of low-rank joint compression of Key/Value: instead of caching full K and V, it caches a set of low-dimensional latent vectors and projects them back up when needed. The effect is a significantly smaller KV cache, lower memory-access pressure, higher decode-phase throughput, while preserving as much of the representational space of multi-head attention as possible. A sketch:
# Illustrative code: read/write approach for a low-rank latent cachec_kv = down_proj(x) # low-dimensional latent representation, written to cachek, v = up_proj_k(c_kv), up_proj_v(c_kv)attn = softmax(q @ k.T / sqrt(d)) @ v
It is worth stressing that low-rank compression loses some representational capacity, so implementations typically pair it with a decoupled positional encoding scheme to keep the compressed latent vectors from interfering with positional information. This is also why evaluating such architectures requires looking at downstream task metrics, not just cache numbers.
4. Context Length, Pretraining, and Alignment
Long-context capability is not something you get by simply enlarging the window; it depends on length extrapolation strategies and data mixtures during pretraining. This generation of models was pretrained on roughly 8.1 trillion tokens of multi-source, high-quality corpus, and completed supervised fine-tuning with about 1.5 million dialogue samples covering multiple domains. The engineering implications of these two numbers are:
- Data quality takes priority over raw volume; deduplication, quality filtering, and domain mixture directly determine the ceiling of the base model.
- Sample diversity in the alignment stage determines instruction-following and multi-turn dialogue quality; insufficient domain coverage shows up as weaknesses in vertical scenarios.
On benchmarks, public results show its Chinese-language general capability in the top tier alongside leading closed-source models of the same period, while its English capability is roughly on par with a 70-billion-parameter dense model and exceeds some sparse models of the same generation. On training efficiency, reaching equivalent results requires about one fifth the compute of a same-generation 70B dense model and about one twentieth that of a leading closed-source model. The right way to use such figures is as an order-of-magnitude reference, not a precise promise—actual performance depends heavily on task distribution, prompt design, and post-processing strategy.
5. Cost Structure and the Knock-On Effect of Pricing Strategy
The low-priced API is the most industry-shaping part of this generation: pricing of 1 RMB per million input tokens and 2 RMB per million output tokens pushed the marginal cost of calling a large model down to a level that is negligible for most businesses, and directly triggered price cuts from several cloud vendors. The takeaway for developers: inference cost is shifting from a budget constraint to an architecture-selection variable.
A practical cost estimation framework:
# Illustrative: estimating monthly cost from call structuredef monthly_cost(calls, in_tok, out_tok, price_in=1.0, price_out=2.0):return calls * (in_tok * price_in + out_tok * price_out) / 1e6
There are usually four optimization directions: shorten prompts, reuse prefix caches, route high-frequency simple requests to a smaller model, and use batching for non-real-time tasks. Sparse-activation models have a natural advantage on all four, because the per-token cost is already lower.
6. Implementation Practice: From Model Selection to Private Deployment
- Scenario fit. Long-context scenarios such as long-document review, codebase understanding, and multi-turn customer support benefit most; for short Q&A, compare latency first rather than context length.
- Private inference. If data cannot leave your environment, evaluate memory and parallelization strategy: weight sharding, expert parallelism, and KV cache compression need joint tuning, and routing communication should be profiled.
- Domestic compute adaptation. This generation has been adapted to domestic AI processors and released on the relevant developer community, and mainstream cloud platforms have completed integration of the full version, with on-demand switching across model generations. For migration, prefer general-purpose container platforms and model-serving capabilities that provide a unified inference interface.
- Observability. Connect a general-purpose logging service and monitoring/alerting, and focus on time-to-first-token, throughput, peak memory, and routing load distribution, so long-tail requests do not drag down the overall SLA.
- Version management. The base model iterates quickly (this series has since been updated to version 2.5), so the business side should pin the model version, build a regression evaluation set, and roll out upgrades gradually.
7. Conclusion
MoE solves the decoupling of capacity and compute; MLA solves the memory wall of long context. Stacked together, they push the usable boundary of hundred-billion-parameter models far outward. For developers, the real payoff is not the numbers on a parameter sheet, but being able to try longer contexts, more complex agent chains, and higher concurrency at the same budget. Three disciplines are enough when putting this into practice: use your own evaluation set as the yardstick, treat memory and latency as hard constraints, and make version pinning plus gradual rollout your release strategy.
