Mixture of Experts (MoE) Explained: How Sparse Architecture Powers Llama 4, Mixtral, and Modern LLMs

MoE article featured image

Mixture of Experts is a neural network architecture that replaces a model's fully connected feedforward layers with a set of smaller expert networks, routing each input token through only a few selected experts via a learnable gating mechanism. Instead of activating every parameter for every token, MoE sparsely activates a subset, reaching hundreds of billions of total parameters while keeping computation and latency comparable to much smaller dense models.

This shift has become the dominant pattern in modern large language models. From Mixtral 8x7B in early 2024 to DeepSeek-V3's staggering 671 billion parameters with only 37 billion active, to Llama 4 Scout and Maverick, nearly every major lab has adopted MoE as the backbone of its frontier open-weight releases.

Key Takeaways
  • MoE replaces fully-connected layers with sparse expert networks, activating only a small subset per token.
  • Total parameters can be enormous while activated parameters stay modest, for example DeepSeek-V3 has 671B total but runs at ~37B cost per token.
  • The routing gate and load-balancing loss determine which experts process each token during training and inference.
  • Key limitations include expert collapse, fine-tuning difficulty, and high memory requirements for storing all experts.
  • By 2026, MoE is the default scaling strategy for open-source LLMs across Mixtral, DeepSeek, Llama 4, and emerging multimodal systems.

What MoE Actually Means in Practice

In a standard dense transformer, every token passes through the same large feedforward network at every layer. MoE replaces those monolithic blocks with collections of smaller expert networks, eight, sixteen, or even one hundred twenty-eight distinct sub-networks per layer.

A trainable gating network, also called a router, decides which one or two experts should handle each token. According to the original Shazeer et al. paper from 2017, which introduced the Sparsely-Gated Mixture-of-Experts layer, the gating mechanism learns to specialize experts for different types of input, such as grammar tasks, factual retrieval, and code generation, while keeping the per-token compute constant regardless of how many experts exist. The team demonstrated this by building an LSTM-based translator that scaled to 137 billion parameters, with only a tiny fraction active per example.

Each expert is essentially a small feedforward network with its own weights. The router sends the token's representation to the top-k experts, sums their outputs weighted by the router's confidence scores, and passes the result forward to the next layer. The model trains both the expert weights and the routing decisions simultaneously, so the experts gradually specialize and the router gets better at sending the right tokens to the right places.

How the Routing Gate Decides

The routing mechanism sits at the heart of every MoE model and determines everything about how it behaves. For each incoming token representation, the gating network produces a set of raw scores, one per expert. A softmax normalizes these into probabilities, and then a top-k selection picks the experts with the highest scores. Most published architectures use k=1 or k=2, meaning each token passes through just one or two experts out of potentially hundreds.

But if the routing were purely greedy, researchers call the outcome "expert collapse". A handful of popular experts absorb nearly all tokens while others sit idle. To prevent this, MoE models introduce an auxiliary load-balancing loss. This term penalizes routing decisions when certain experts are overused or underused, pushing the system toward a more even distribution. Hugging Face's detailed MoE explainer notes that load balancing and a technique called router Z-loss are critical for keeping MoE training stable; without them, the router can converge on bad local optima and the model stops learning effectively.

Router Z-loss modifies the raw gating logits before the softmax step. It adds a penalty proportional to the squared log-sum-exp of those logits, which prevents extreme probability distributions from collapsing into a single expert. Combined with the auxiliary loss, this stabilizes the routing across training and keeps expert utilization relatively uniform, a prerequisite for the model to actually benefit from its full parameter count.

Dense Models vs MoE: The Math Behind the Efficiency Gain

The fundamental difference between dense and MoE models comes down to one thing: total parameters versus activated parameters.

A 70 billion parameter dense model activates all 70B per token. An MoE with 70B total split across eight experts with k=2 activates roughly 17.5B. Total parameters absorb broad knowledge while per-token compute scales with the activated budget. According to Meta's blog post on Llama 4, both Scout and Maverick activate approximately 17 billion parameters per token despite having vastly different totals. Scout uses around 16 experts while Maverick employs roughly 128.

The FLOPs-per-token approximation follows a similar relationship. For a decoder-only transformer, approximate FLOPs scale linearly with the number of activated parameters. This means a 400-billion-parameter MoE running at 17B activated cost is computationally comparable to a 17-billion-parameter dense model, even though the MoE absorbs far more information across its entire expert pool. According to Hugging Face's Mixtral announcement, Mixtral 8x7B decodes at approximately 12 billion dense speed despite carrying roughly 45 billion total parameters. That efficiency gap is what drives the MoE choice in modern models.

The MoE Landscape in Modern Models

Several major open-weight models released in 2024 and 2025 made MoE the central architectural decision.

Mixtral 8x7B and 8x22B. Hugging Face's Mixtral line was one of the first Apache 2.0 licensed MoE models to hit mainstream attention. Both variants replace some feedforward layers with sparse MoE blocks using 8 experts and top-2 routing. The 8x7B carries about 45B parameters total and reportedly outperformed GPT-3.5 on MT-Bench. Mixtral remains available under a permissive license, though it is effectively unmaintained since its initial release.

DeepSeek-V3. The technical report from DeepSeek describes a model with 671 billion total parameters and 37 billion activated per token. The model combines Multi-head Latent Attention for more compact context encoding with DeepSeekMoE, a novel routing scheme that removes the need for auxiliary losses during training. DeepSeek's design departs substantially from earlier MoE approaches and indicates the field continues to evolve its understanding of efficient expert routing.

Llama 4 Scout and Maverick. Meta's latest open-weight family introduces a natively multimodal architecture built on MoE principles. Scout activates 17B parameters across roughly 16 experts, while Maverick maintains the same 17B activation budget but expands to approximately 128 experts, bringing the total parameter count near 400 billion. Both models share the same activated size, making them comparable in inference cost while Maverick provides substantially more total capacity for handling diverse modalities.

Why Labs Adopted MoE at Scale

The motivation is straightforward. Scaling dense models costs money in two dimensions: more GPU-hours for training and bigger hardware clusters. With MoE, the total parameter budget grows without proportionally increasing per-token compute because each token sees only a fraction of the experts.

According to the foundational literature on MoE scaling, the primary advantage is specialization without proportional compute. Each expert can learn domain-specific patterns while the router steers tokens to the right specialists. Inference cost stays manageable because you move data through only a subset of the parameters.

Memory and bandwidth have emerged as the new bottleneck. When all 400 billion of Maverick's parameters live on GPU, VRAM becomes the constraining factor rather than raw FLOPs. This is why serving infrastructure for MoE models focuses heavily on expert parallelism, distributing different experts across different GPUs or nodes so the full parameter set fits without requiring impossibly large single-card memories.

The Limitations No One Ignores Forever

MoE is not a free lunch. Several problems keep coming up in research and production experience, and they tend to compound as expert counts grow past the hundreds.

Fine-tuning MoE models remains challenging because adjusting the router can destabilize the entire load balance. Hugging Face's MoE blog explicitly flags fine-tuning as an open difficulty area. A model trained with carefully balanced expert utilization will redistribute its routing if you update only a subset of the experts, potentially creating the very collapse the auxiliary losses tried to prevent. For practical workflows, this often means full fine-tuning is preferred over parameter-efficient methods like LoRA, which increases the compute footprint considerably.

Expert collapse is a known issue: certain experts capture most of the training signal while others go unused, and the auxiliary terms cannot guarantee that every expert learns something useful. Training instability is another well-known risk. Large MoE models frequently show erratic convergence behavior during the early training phases, particularly when the routing distribution has not settled into a stable pattern. The router Z-loss helps but does not eliminate the problem entirely.

Where MoE Is Headed Next

Multimodal MoE is one of the most active frontiers. Instead of routing tokens based purely on text patterns, future routers could route across image patches, audio frames, and text tokens simultaneously. Specialized experts would handle visual processing, speech recognition, and language understanding within a single shared architecture. Early prototypes already point in this direction.

The concept also extends beyond network parameters. "Mixture of agents" or "mixture of models" architectures route entire inputs to different specialized models rather than different expert layers. Instead of a router choosing between eight small feedforward networks inside a transformer, the router chooses between GPT-5, Claude, Gemini, or a local quantized model to handle a given prompt. This approach lets organizations dynamically pick the cheapest capable model for each task rather than relying on a single expensive model for everything.

Should You Care About MoE as a Developer?

If you are deploying language models in production, MoE affects hardware requirements, inference costs, and fine-tuning strategy. Serving an MoE model requires careful consideration of GPU memory topology. Expert parallelism is not optional for models larger than a single card can hold.

When deciding whether to run an MoE model or a dense alternative of comparable quality, the activated parameter count gives you a reasonable estimate of inference cost while the total parameter count tells you about the minimum VRAM required. A 671B parameter model like DeepSeek-V3 will consume several times more GPU memory than a dense 30B model even though it processes tokens at roughly equivalent compute. If your deployment target has generous GPU memory but constrained budgets, MoE makes sense. If your constraint is tight memory with access to good dense alternatives, the math may favor the simpler path.

Conclusion

Mixture of Experts has transitioned from an academic curiosity in 2017 to the default scaling architecture for every major open-weight language model in 2026. By separating total model capacity from per-token compute cost, MoE lets researchers push parameter counts into the hundreds of billions while keeping inference practical. The trade-off is real: training stability, fine-tuning complexity, and serving infrastructure that engineers need to plan for from day one.

Frequently Asked Questions

What is the main difference between MoE and dense transformers?
In a dense transformer, every token passes through the full set of model parameters. In a Mixture of Experts model, a routing gate selects only a small subset of "expert" networks for each token, so the per-token computation scales with the activated parameters rather than the total parameter count. This allows much larger total models at roughly the same inference cost.

How many experts does a typical MoE model use?
It varies widely. Mixtral uses 8 experts per MoE layer, Llama 4 Scout uses around 16, and Llama 4 Maverick uses approximately 128. DeepSeek-V3 uses a different configuration optimized for its deepseekMoE routing design. The number of experts scales with total model size and the desired specialization granularity.

Can you fine-tune an MoE model with LoRA?
Technically yes, but it is not recommended without caution. Applying LoRA selectively to some experts breaks the load balance the model was trained under, which can cause degradation in capability. Hugging Face and other sources note that full fine-tuning tends to work more reliably for MoE models, at the cost of higher compute requirements compared to parameter-efficient methods.

References

  1. Shazeer, N. et al. (2017). "Sparsely-Gated Mixture-of-Experts Layers." arXiv:1701.06538
  2. Hugging Face. (2024). "Mixtral 8x7B." huggingface.co/blog/mixtral
  3. Hugging Face. (2024). "Mixture of Experts Explained." huggingface.co/blog/moe
  4. DeepSeek Team. (2024). "DeepSeek-V3 Technical Report." arXiv:2412.19437
  5. Meta AI. (2026). "Introducing Llama 4: Multimodal Intelligence at Every Scale." ai.meta.com/blog/llama-4-multimodal-intelligence

Post a Comment

0 Comments