MoE Architecture Evolution: From General-Purpose LLMs to Ultra-Long Context

    This article reviews the architectural evolution of Mixture-of-Experts (MoE) models, focusing on how MoE decouples model capacity from per-token computation. It covers fine-grained expert segmentation, shared expert mechanisms, latent KV compression for attention, and the training and inference strategies used to extend context windows to the million-token level. It also summarizes key engineering practices such as load balancing, communication overhead, and long-range evaluation, helping readers understand the motivations and trade-offs behind these designs.

    1. Background: The Scaling Dilemma of Large Models

    In recent years, the capability gains of large language models have depended heavily on expanding parameter scale. However, the scaling path of dense architectures has an inherent contradiction: as parameter count grows, compute and memory costs rise linearly or even superlinearly, and inference costs surge accordingly. It is widely observed that in dense models, every parameter participates in every forward computation during training, tightly coupling computation with model capacity.

    Mixture-of-Experts (MoE) architecture was created to decouple this relationship. Its core idea is to split the feed-forward network layer into multiple “expert” sub-networks and use a router to dynamically select a small number of experts for each token. This keeps the total parameter count large while keeping the computation per forward pass controllable. The idea itself is not new, but making it stable and efficient to train and serve in engineering practice has been a key challenge in recent years.

    2. Two Key Improvements in MoE Architecture

    2.1 Fine-Grained Expert Segmentation

    Traditional MoE usually uses a small number of large-capacity experts, such as 8 or 16, with each expert having a parameter scale comparable to a dense layer. This design offers a limited routing combination space and makes it difficult to express complex knowledge combinations. Fine-grained expert segmentation further divides each expert into more and smaller expert units—for example, refining 16 experts into 64 or more—while proportionally increasing the number of activated experts per token.

    From a combinatorial perspective, if the total number of experts is N and the number of activated experts is K, the theoretical number of expressible combinations is C(N, K). With more experts and smaller individual experts, the same compute budget can cover a richer set of knowledge combinations. For example:

    1. # Combination space example
    2. from math import comb
    3. # Coarse-grained: choose 2 from 8
    4. print(comb(8, 2)) # 28
    5. # Fine-grained: choose 6 from 64
    6. print(comb(64, 6)) # 74974368

    As shown, fine-grained segmentation expands the combination space by several orders of magnitude with almost the same activated computation, significantly improving model flexibility and knowledge specialization.

    2.2 Shared Expert Mechanism

    Fine-grained segmentation introduces a problem: knowledge redundancy may appear across experts, with multiple experts repeatedly learning common patterns. The shared expert mechanism addresses this by setting up a small number of “always-on” shared experts dedicated to cross-scenario general knowledge, while routed experts focus on more specialized domain knowledge. An isolation mechanism prevents the two from learning the same information repeatedly.

    This “general + specialized” layered design brings two benefits:

    • Improved parameter efficiency: General knowledge is stored centrally, reducing redundant parameter usage.
    • Inference friendliness: Shared experts can reside permanently in high-speed caches or compute units, and their computation is stable, making operator fusion and scheduling optimization easier.

    3. Supporting Innovation in Attention: Latent Compression

    MoE mainly optimizes the feed-forward layer, while the KV cache overhead of the attention layer in long-sequence scenarios is another major bottleneck. Traditional multi-head attention must cache full Key/Value tensors during inference, and their size grows linearly with sequence length, creating severe memory pressure in long-context inference.

    The multi-head latent attention (MLA) approach provides a compression scheme: KV is compressed into a latent space through low-rank projection, and inference only needs to cache the compressed latent vectors, which are restored during computation with an up-projection matrix. It also introduces a decoupled positional encoding structure that balances the long-range decay characteristics of rotary positional encoding with the need for KV compression. Compared with traditional key-value caching, this approach can compress cache usage by an order of magnitude and noticeably improve inference throughput.

    4. Toward Ultra-Long Context: From Architecture to Training Strategy

    Extending the context window to the million-token level usually requires coordination across multiple layers.

    4.1 Positional Encoding Extrapolation

    For models based on rotary positional encoding, longer sequences are generally supported by adjusting base frequency parameters, or by introducing progressive length-extension training in late pretraining so that the model first adapts to medium-to-long text and then scales up step by step.

    4.2 Training Data and Stage Design

    Long-context capability cannot be obtained by changing the architecture alone. It usually requires mixing large amounts of long-document data in late pretraining and arranging training stages in a short-to-long curriculum, gradually increasing sequence length to avoid training instability.

    4.3 Inference-Side Optimization

    • Sparse attention: Use a hybrid attention pattern of local windows plus global anchors for ultra-long sequences to reduce computational complexity.
    • Chunked prefill and streaming decoding: Process long prompts in chunks to control peak memory.
    • Tiered KV cache management: Combine latent compression with placement of part of the cache in lower-cost storage tiers.

    5. Engineering Practice Highlights

    1. Load balancing is a prerequisite for stable training: Uneven routing can cause some experts to become “hot” while others sit idle. Auxiliary losses or dynamic bias terms are needed to constrain expert load.
    2. Communication overhead cannot be ignored: Expert parallelism in MoE introduces cross-device All-to-All communication, which must be carefully designed together with parallelism strategy and network topology.
    3. Evaluation must cover long-range dependencies: Long-context models should be tested on retrieval, multi-hop reasoning, and cross-paragraph consistency, not just perplexity.

    6. Conclusion

    From fine-grained expert segmentation to shared expert mechanisms, and then to latent-compression attention and million-level context extension, the evolution of MoE architecture shows a clear path: systematically reducing training and inference costs without sacrificing, and sometimes even improving, effectiveness. For developers, understanding the motivations and trade-offs behind these architectural designs helps them make more reasonable judgments when building or selecting large model services, and also lays a solid efficiency foundation for subsequent multimodal and agent applications.