Introduction
Welcome to our next lesson in the "Scaling with Mixture-of-Experts" module.
In our previous lesson, we investigated the load balancing problem, a critical challenge in training MoE models. You learned how an unconstrained router can lead to "routing collapse" and how auxiliary loss functions are used to enforce a more even distribution of tokens among experts.
Today, we will see how these concepts are refined and implemented in a state-of-the-art model. Our learning goal is to explain DeepSeek-V3's MoE design with its use of shared and routed experts. We will build directly on your understanding of MoE basics and load balancing to dissect a more sophisticated and efficient architecture.
Specifically, we will cover:
- The limitations of standard MoE that DeepSeek's design aims to solve.
- The core innovation of partitioning experts into shared (always active) and routed (conditionally active) groups.
- DeepSeek's novel "auxiliary-loss-free" approach to load balancing.
By the end of this lesson, you will understand the specific architectural choices that make models like DeepSeek-V3 both powerful and efficient.
1. The Redundancy Problem in Standard MoE
First, let's consider why an innovation like DeepSeekMoE was necessary. Standard MoE architectures, while powerful, suffer from an inherent inefficiency.
Understanding DeepSeek Part I: DeepSeekMoE
To understand the motivation behind DeepSeek's design, let's start with this article that clearly articulates the core problem with standard MoE.
Read the first three paragraphs of the 'Paper Summary' section. Focus on the explanation of why activating only a few large experts forces them to learn redundant information, leaving less room for true specialization.
As the article explains, when only a small number of large experts are activated for a given token, those experts are forced to handle all aspects of that token's processing. This includes fundamental, "common knowledge" tasks like understanding basic syntax or grammar, which are relevant to nearly all tokens.
This creates a significant problem: a large portion of each expert's capacity is wasted re-learning and storing the same redundant information. This leaves less capacity for the true goal of MoE: developing a diverse set of specialized experts.
2. DeepSeek's Solution: Shared and Routed Experts
DeepSeek's primary innovation is to solve this redundancy problem by partitioning the experts into two distinct categories. This new architecture is called DeepSeekMoE.

2.1. Shared Experts
As the name implies, shared experts are feed-forward networks that are always activated for every token.
- Role: Their job is to learn the broad, common knowledge required by all inputs. Think of this as the model's "core curriculum"—syntax, high-level semantics, and other fundamental patterns of language.
- Benefit: By dedicating a specific set of parameters to this common knowledge, the model frees up the other experts to specialize without having to waste their capacity on redundant information.
2.2. Routed Experts
These are the specialist networks that we are familiar with from the basic MoE architecture. They are conditionally activated based on the decisions of the router network.
- Role: Since the shared experts handle the fundamentals, these routed experts can focus entirely on learning niche, domain-specific knowledge. One expert might specialize in Python syntax, another in medical terminology, and another in historical facts.
- Benefit: This division of labor promotes much greater parameter efficiency and allows the model to develop a far more diverse and specialized set of skills.
The combination of these two expert types is the cornerstone of the DeepSeekMoE architecture. Let's look at the mathematical formulation from the technical report.
The output of a DeepSeekMoE layer, , for a given token at layer is a combination of three components:
Where:
- is the input to the MoE layer (from the attention sub-layer).
- The first sum is over the shared experts, which are all applied to the input.
- The second sum is over the routed experts, where is the gating value from the router, which is non-zero only for the top-K selected experts.
The following video provides a clear walkthrough of this combined architecture.
The 'DeepSeek-V3' video by Gabriel Mongaras provides an excellent step-by-step explanation of how the shared and routed experts work together.
Watch the segment from 16:51 to 21:59. Pay close attention to how the input token is processed simultaneously by the skip connection, the shared experts, and the routed experts, and how their outputs are ultimately summed.
3. Further Innovations in DeepSeekMoE
Beyond the shared/routed expert split, the DeepSeek architecture incorporates two other key ideas to maximize efficiency and performance.
3.1. Fine-Grained Experts
Instead of using a few very large experts, DeepSeek opts for a much larger number of smaller, "fine-grained" experts.
Understanding DeepSeek Part I: DeepSeekMoE
This is a simple but powerful idea with significant consequences for the model's representational capacity. The 'Understanding DeepSeekMoE' article provides a fantastic combinatorial example.
Read the section 'Fine-Grained Expert Segmentation'. Focus on the example comparing a standard MoE with 8 large experts to a DeepSeekMoE with 64 smaller experts. Note how this increases the number of possible expert combinations from 28 to nearly 489 trillion without changing the total or active parameter counts.
This "free lunch," as the article calls it, dramatically increases the model's flexibility and potential for specialization on a token-by-token basis, all while maintaining the same computational budget.
3.2. Auxiliary-Loss-Free Load Balancing
In our last lesson, we saw how auxiliary losses are used to prevent routing collapse. While effective, this adds another term to the loss function that the model must optimize, creating a trade-off between task performance and load balance.
DeepSeek pioneers a clever strategy to achieve load balance without a dedicated loss term.
Mixture of Experts (MoE), Visually Explained
This is a significant evolution from the techniques we studied previously. This visual explanation will make the mechanism clear.
Watch the segment 'DeepSeek V3 Load Balancing' from 24:34 to 26:16. Focus on how a learnable bias term is dynamically adjusted for each expert based on whether it is 'overloaded' or 'underloaded' in a given training batch.
This dynamic bias adjustment gently "nudges" the router towards a balanced state without interfering with the main optimization objective. As shown in the technical paper's ablation studies, this method allows for greater expert specialization compared to a rigid auxiliary loss.
4. The DeepSeek-V3 MoE Configuration
Let's make these concepts concrete by looking at the actual hyperparameters used in the DeepSeek-V3 model, as detailed in its technical report.
For most of its MoE layers, DeepSeek-V3 uses:
- Total Experts: 257 per layer.
- Shared Experts: 1
- Routed Experts: 256
- Activated Experts per Token (K): 8
This configuration highlights their design philosophy: one "generalist" shared expert handles the common workload, while a large pool of 256 fine-grained specialists are available for the router to choose from, with 8 being activated for any given token.
Conclusion
In this lesson, we deconstructed the highly effective DeepSeekMoE architecture.
Key Takeaways:
- Shared vs. Routed Experts: DeepSeek solves the expert redundancy problem by splitting FFNs into a shared expert (always on, for common knowledge) and a pool of routed experts (conditionally on, for specialized knowledge).
- Fine-Grained Specialization: It uses a large number of smaller experts, which massively increases the combinatorial space of expert selections for each token without increasing computational cost.
- Auxiliary-Loss-Free Balancing: Instead of a fixed auxiliary loss, DeepSeek dynamically adjusts a bias term for each expert's routing score, achieving better balance and allowing for more natural specialization.
Preview of the Next Lesson:
The design of MoE models, particularly the use of many experts with only a few activated per token, leads to a crucial distinction: the difference between a model's total parameters and its active parameters. In our next lesson, we will formalize this concept, quantify these two numbers for models like DeepSeek-V3, and understand why this distinction is the key to scaling models to trillions of parameters while keeping them computationally feasible.