Foundations of Mixture of Experts
local graph
Chapter 1 — Foundations of Mixture of Experts
Section titled “Chapter 1 — Foundations of Mixture of Experts”The Scaling Dilemma: Dense Transformers vs. Conditional Computation
Section titled “The Scaling Dilemma: Dense Transformers vs. Conditional Computation”The transformer architecture has driven most of the remarkable progress in large language models over the past six years, but it carries an intrinsic inefficiency: every token in every forward pass activates every parameter in the model. A 70-billion-parameter dense model expends 70 billion multiply-accumulate operations per token, regardless of whether the input is a trivial greeting or a complex mathematical derivation that genuinely demands the full breadth of the model’s knowledge. This universal activation is computationally wasteful and, more importantly, it creates a hard coupling between model quality - which scales with total parameter count - and inference cost - which scales with the same parameter count. Mixture of Experts architectures break this coupling by activating only a learned subset of parameters for each token, enabling models with far larger total parameter counts to be trained and served at costs comparable to much smaller dense models.
The conditional computation idea - the notion that a computational system should invest more processing resources in difficult inputs than in easy ones - predates the transformer era by several decades. Geoffrey Hinton and colleagues explored conditional computation in the context of modular neural networks in the 1990s, and Jordan and Jacobs described the Mixture of Experts framework for supervised learning in 1991, long before deep learning made the concept practical at scale. The key insight of the Jordan-Jacobs formulation remains central to modern MoE LLMs: a gating network learns to route each input to the expert or combination of experts most suited to process it, with the overall system learning both the expert specializations and the routing policy through joint end-to-end training.
Modern MoE language models insert MoE layers in place of some or all of the feed-forward network sublayers in the standard transformer block. While the attention sublayer remains unchanged - processing the full sequence with all its parameters - the FFN sublayer is replaced by a set of E expert networks, each with the same architecture as the original FFN but operating independently. A gating network selects the top-k experts for each token, and only those k experts perform computation for that token. The total parameter count of the model scales linearly with E, but the compute cost per token scales only with k, enabling the famous ‘sparse’ property of MoE: the model can be made arbitrarily parameter-rich by adding more experts without proportionally increasing compute per token.
The engineering appeal of MoE architectures is concrete and measurable. Mixtral 8x7B, released by Mistral AI in December 2023, demonstrated that a model with 46.7 billion total parameters but only 12.9 billion active parameters per token could match or exceed the performance of much larger dense models like Llama 2 70B on most benchmarks, while requiring significantly less computation per token during inference. DeepSeek-V2, released in May 2024, took this further with 236 billion total parameters and only 21 billion active per token, achieving state-of-the-art performance with dramatically lower training compute than equivalent dense models. These results validated MoE as a mature and practical architecture for production LLM deployment.
Understanding MoE architectures requires familiarity with three distinct but interacting design problems: expert design, gating design, and training stability. Expert design asks what each expert should look like and how many experts should be used. Gating design asks how to route tokens to experts, what the routing policy should optimize, and how to prevent pathological routing behaviors such as all tokens selecting the same expert. Training stability asks how to handle the discrete routing decisions that sit in the gradient path, how to encourage expert specialization without causing expert collapse, and how to maintain consistent training dynamics across a model that may contain hundreds of expert networks spread across dozens of layers.
Dense Transformer FFN Sublayer
┌─ Feed-Forward Network (FFN) ─┐ Token │ ┌──────────────────┐ │ Representation ──▶│ │ Linear (W₁, b₁) │ │──▶ Output (y) (x) │ ├──────────────────┤ │ │ │ RELU │ │ │ ├──────────────────┤ │ │ │ Linear (W₂, b₂) │ │ │ └──────────────────┘ │ └──────────────────────────────┘ │ Output (y)
Mixture-of-Experts (MoE) Layer
┌ Top-k Selection (k) ┐ ┌─────────────────────────────────────────┐ ┌──────────┐ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │ Gating │─▶│ │Expert│ │Expert│ │Expert│ │Expert│ │Expert│ │──▶ Output (y) │ Network │─▶│ │ FFN │ │ FFN │ │ FFN │ │ FFN │ │ FFN │ │ │ (G) │─▶│ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘ │ ─── Incative └──────────┘ └─────────────────────────────────────────┘ Experts │ │ └──▶ Sum & Scale ◀──┘ │ Output (y)[!visual-conversion] Both panels are transcribed. The five expert boxes carry blurred sub-labels in the print (“FFN₁ … N”, “FFN 2 / FFN 3 / FFN N” and similar) that cannot be read reliably; they are omitted. “Incative” is as printed.
Historical Development and Key Milestones
Section titled “Historical Development and Key Milestones”The Jordan-Jacobs Mixture of Experts paper of 1991 established the foundational mathematical framework: a set of expert networks each modeling a conditional distribution over outputs, and a gating network whose softmax outputs serve as mixing coefficients. The expectation-maximization algorithm was used to jointly train the experts and the gating network, with each expert specializing in the region of input space where its gating weight is high. This statistical framing influenced subsequent work but was limited to shallow, fully connected expert architectures and small datasets by the computational constraints of the era.
The critical modern breakthrough came in Noam Shazeer and colleagues’ 2017 paper ‘Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer.’ This work introduced sparse gating - selecting only the top-k experts by gating score rather than using a soft mixture of all experts - and demonstrated that MoE layers could be integrated into LSTM language models at a scale of up to 137 billion parameters, achieving state-of-the-art perplexity at lower compute cost than dense baselines. The paper introduced the auxiliary load balancing loss that would become a standard component of every subsequent MoE training recipe, and identified expert collapse and load imbalance as the two principal failure modes requiring active mitigation.
Google’s Switch Transformer, introduced in 2021, simplified the Shazeer design by using k=1 routing (selecting exactly one expert per token) and demonstrated that this extreme sparsity could be applied to T5-scale encoder-decoder transformers with significant gains in training efficiency. The Switch Transformer training results showed that for a fixed compute budget, MoE models could achieve lower perplexity than dense models of the same size, and that this advantage was preserved across a range of model scales from millions to hundreds of billions of parameters. The paper also introduced several engineering improvements to training stability including a capacity factor mechanism and selective use of precision in the gating computation.
The open-source availability of Mixtral 8x7B weights in December 2023 was a landmark event that made MoE architecture engineering accessible to the broader research and engineering community. For the first time, practitioners could inspect, fine-tune, and serve a state-of-the-art MoE model without access to proprietary infrastructure, enabling rapid experimentation and community-driven improvements. The analysis of Mixtral’s internal expert routing behavior - showing that different experts develop consistent specializations for different domains and linguistic phenomena - provided empirical evidence for the theoretical claims about expert specialization that had motivated MoE research for decades.
The emergence of DeepSeek’s MoE architectures in 2024, culminating in DeepSeek-V3 and DeepSeek-R1, demonstrated that MoE could achieve frontier-level capabilities at a fraction of the training cost of equivalent dense models. DeepSeek’s innovations in Multi-head Latent Attention combined with fine-grained MoE - using many smaller experts rather than fewer large ones - and auxiliary-loss-free load balancing through bias term adjustment represented significant advances in the engineering of practical MoE systems. The public availability of DeepSeek model weights and technical reports accelerated the pace of MoE research across the global ML engineering community.
MoE Architecture Milestones (1991-2025)
| Axis mark | Milestone | Year | Key innovation and scale (as printed) |
|---|---|---|---|
| 1990 | Jordan-Jacobs | 1991 | Key Innovation: Gating Network for Experts. Model Scale: <10⁶ Parmeters |
| 1995 | Shazeer at. 2017 — Sparsely-Gated MoE | Key Innovation: Learnable Sparse Spare Gating. Large-Scale App. Model <10⁹ Parmeters | |
| 2000 | Switch Transformer | Key Innovation: Simplified One-Expert Routing. Model Scale: <1.21.11 Parmeters | |
| 2015 | GLaM | 2022 | Key Innovation: Multi-Gated Experts, Pre-training Efficiency. Model <1.2 Trillion Parmeters |
| 2020 | Mixtral | 2023 | Key Inovation: Open-Source, 8x7B Model. Fine-Enale, ~45B Parmeters (Effective) |
| 2025 | DeepSeek-V2 | 2024 | Rey Ratary-Spike MoE, Fine-Grained Experts, ~236B Parm (Effective) |
Bottom axis: “Model Parameters (log scale)”, ticks as printed: 103 · 105 · 100 · 100 · 105 · 100 · 1012.
[!visual-conversion] The timeline’s six milestones are transcribed left to right, with every label as printed, including the figure’s own errors (axis years that do not match the milestone years, “Parmeters”, “Spare Gating”, “<1.21.11”, “Fine-Enale”, “Rey Ratary-Spike”, the garbled log-scale ticks). Lost: the small decorative icon under each milestone. Labels marked as small and blurred in the scan were read from a zoomed crop; “Shazeer at.” and “Learnable” are best readings.
MoE vs. Dense Architecture: Trade-offs and When to Use Each
Section titled “MoE vs. Dense Architecture: Trade-offs and When to Use Each”The decision between MoE and dense architectures for a new LLM project is not simply about performance maximization - it involves trade-offs in training cost, serving infrastructure, memory requirements, and engineering complexity that must be evaluated against the specific use case and resource constraints. MoE architectures offer superior parameter efficiency during training: for a fixed compute budget, a MoE model will generally achieve lower loss than a dense model because it can encode more knowledge in its larger total parameter count. However, MoE models also require more memory to store all expert weights during inference, and the routing and dispatch overhead introduces latency that can be significant in latency-sensitive serving environments.
Memory bandwidth is often the binding constraint in LLM serving, and MoE architectures have a complex relationship with this constraint. In batch serving scenarios where many requests are processed simultaneously, the fraction of active experts per batch tends to be high as different inputs activate different experts, requiring most of the model’s parameters to be resident in GPU memory to avoid costly reload operations. This contrasts with the theoretical promise of MoE - that only a small fraction of parameters need to be active at any time - which holds per-token but not necessarily per-batch. Efficient MoE serving therefore requires either very large GPU memory capacity, expert parallelism across multiple GPUs, or sophisticated expert caching strategies.
The engineering complexity overhead of MoE should not be underestimated, particularly for teams without prior experience with sparse models. Training a MoE model requires careful tuning of the auxiliary loss weight, the expert capacity factor, and the routing algorithm to avoid training instability, expert collapse, or severe load imbalance. Serving requires implementing and maintaining the expert routing and dispatch logic, potentially across multiple GPU nodes. Debugging failures in MoE training requires understanding the interaction between routing dynamics, load balancing, and gradient flow in a way that has no direct analog in dense model training. For teams with limited infrastructure, a well-optimized dense model may deliver better practical outcomes than a nominally superior MoE model that is difficult to train and serve reliably.
The ideal use case for MoE architectures is scenarios where the total parameter count matters - either because the task requires broad knowledge that benefits from a large number of parameters, or because a large model is needed to meet a quality bar - but compute budget is constrained. This combination is extremely common in production LLM deployments: a serving team with a fixed GPU budget wants the highest quality model it can run at acceptable latency, making the parameter efficiency of MoE directly valuable. As GPU memory capacity increases and MoE serving infrastructure matures, the engineering overhead of MoE is decreasing relative to its quality benefits, making MoE an increasingly attractive choice for a broader range of deployment scenarios.

AI Model Trade-Offs: Dense vs. MoE (radar chart; legend: Dense Model, MoE Models).