5.5 MoE Routing in Mixtral, DBRX, and DeepSeek
Mixtral 8x7B selects two of eight experts in each layer. DBRX selects four of sixteen. Each routes a token to a quarter of its experts, yet Mixtral has 28 possible expert sets per layer and DBRX has 1,820. What can you infer from those counts? Start with the weights a server must hold, then follow the work it actually performs for one token. [1] [8]
1. Expert weights in Mixtral 8x7B
Mixtral 8x7B provided public weights and a technical report for inspecting sparse MoE behavior directly. [1] It does not establish GPT-4 parameter counts or internal architecture, which remain undisclosed.
Counting parameters across eight experts
Mixtral stores one set of shared weights, including attention and embeddings, plus separate feed-forward weights for each expert. The paper reports roughly 47 billion parameters in total and 13 billion active per token. [1]
Let count all shared parameters and let count the parameters of one expert per layer, summed across layers. Experts within a layer have equal size, so the choice of expert does not change the count.
Sending a token to two experts
For input state , let contain the indices of the two experts with the highest router scores. Applying a softmax to those two scores gives weights that sum to one. If expert returns , their combined output is
The next token may need an expert that this token skipped. A server that keeps every expert resident must budget for the full weights. Latency also depends on where each token is dispatched and how much work each expert receives in the batch.
2. Expert combinations in DBRX
DBRX also routes tokens to feed-forward experts. Databricks reports 132 billion total parameters and 36 billion active per token. [8]
How many groups of four can the router choose?
Each layer selects distinct experts from equally sized experts. Ignoring order, there are possible sets.
- Mixtral (8 choose 2): possible paths.
- DBRX (16 choose 4): possible paths.
DBRX offers about 65 times as many unordered expert subsets per layer. That combinatorial count does not measure learned specialization, realized expressivity, or quality by itself: expert size, routing, data, and optimization differ.
How MegaBlocks processes overflow assignments
Route six tokens through one layer. To make the counts easy to follow, choose one expert per token. Expert A gets four assignments (T1–T4), B gets two (T5–T6), and C gets none. Each bracket below holds two token rows. This is an example tile size.
| Expert | Two reserved rows per expert | Two-row tiles allocated as needed |
|---|---|---|
| A | [T1 T2] · T3 and T4 overflow | [T1 T2] [T3 T4] |
| B | [T5 T6] | [T5 T6] |
| C | [empty empty] | No tile |
The fixed layout leaves two rows empty at C while two assignments at A miss this layer’s expert computation. Giving A a second tile processes all six. MegaBlocks handles uneven token counts with block-based operations. The expert weights keep their shape as the number of blocks varies. With counts of three, two and one instead, the two-row tiles would still leave two padding rows. [2]
3. Weight storage in Grok-1
xAI reports 314 billion total parameters for its Grok-1 base model. [3]
Grok-1 uses Top-2 expert routing [3]. Selecting two of eight experts does not establish that exactly one quarter of total model parameters are active: shared attention, embeddings, and expert sizes also matter. A total-parameter fraction is not a substitute for a documented active-parameter definition.
At 314B parameters, raw 16-bit weight payload alone is approximately 628 GB in decimal units. This excludes KV state, activations, workspaces, allocator reserve, and communication. Required device count depends on usable memory and the chosen layout; an eight-device node is not a guarantee that the complete serving workload fits.
4. DeepSeek-V3: Coordinating Routing, Precision, and Systems
The 2024 DeepSeek-V3 report provides a documented combination of sparse experts, latent attention, FP8 training, and multi-token prediction [4]. Its GPU-hour accounting applies to the reported training stages, not all research, failed experiments, data preparation, or deployment costs. Undisclosed competitors’ compute does not support a quantified cost ratio.
DeepSeek-V3 features 671B total parameters but only 37B active parameters per token. This extreme sparsity (activating ~5.5% of parameters) is achieved through several radical architectural innovations.
DeepSeekMoE: Shared + Fine-Grained Routed Experts
Instead of a standard routing pool, DeepSeek-V3 splits its FFN into two distinct types of experts:
- Shared Experts: 1 expert that is always activated for every token. This expert captures common linguistic structures and general knowledge, acting as the dense backbone of the network.
- Routed Experts: 256 highly specialized, fine-grained experts. The router selects up to 8 of these per token.
Shared experts provide always-active capacity while routed experts specialize conditionally. This division does not guarantee that collapse cannot occur; balancing and numerical stability remain part of the training system.
Auxiliary-Loss-Free Load Balancing
Auxiliary balancing can trade task preference against utilization; its effect depends on coefficient and balancing scope. DeepSeek-V3 adjusts a non-gradient bias for expert selection while computing mixture weights from unmodified affinities. It also retains a small sequence-wise auxiliary term [4]. Changing dispatch changes the experts that receive gradients, so “detached” does not mean routing is untouched by balancing. See Chapter 5.4 for the complete distinction.
Implementing Auxiliary-Free Routing
Below is a PyTorch implementation demonstrating the core concept of DeepSeek-V3’s dynamic bias routing. Notice how the bias is applied only for the Top-K selection, while the actual gating weights used for the FFN combination are derived from the unbiased logits.
Educational router only. This isolates affinity selection and normalization; it omits node-limited routing, shared experts, output scaling, global load aggregation and the sequence-wise auxiliary term. It is not a complete DeepSeek-V3 training implementation.
import torch
import torch.nn as nn
import torch.nn.functional as F
class DeepSeekAuxFreeRouter(nn.Module):
def __init__(self, d_model: int, num_routed_experts: int, top_k: int):
super().__init__()
# The router network (no bias in the linear layer itself)
self.gate = nn.Linear(d_model, num_routed_experts, bias=False)
self.top_k = top_k
# The dynamic bias term for load balancing (not updated via backprop)
self.register_buffer("expert_bias", torch.zeros(num_routed_experts))
def forward(self, x: torch.Tensor):
# x shape: [batch_size, seq_len, d_model]
logits = self.gate(x) # [B, S, E]
# Select using biased affinities, combine using unbiased affinities.
affinities = torch.sigmoid(logits.float())
selection_scores = affinities + self.expert_bias
_, topk_indices = torch.topk(selection_scores, self.top_k, dim=-1)
gate_weights = affinities.gather(-1, topk_indices)
gate_weights = gate_weights / gate_weights.sum(dim=-1, keepdim=True).clamp_min(1e-12)
return gate_weights, topk_indices
@torch.no_grad()
def update_bias(self, expert_load: torch.Tensor, target_load: torch.Tensor, step_size: float = 0.001):
"""
Called at the end of a training step.
expert_load: The actual number of tokens routed to each expert in this batch.
target_load: The ideal uniform distribution of tokens.
"""
# If load > target, diff is negative -> bias decreases.
# If load < target, diff is positive -> bias increases.
load_diff = target_load - expert_load
# DeepSeek uses a sign-based or proportional update rule
self.expert_bias += step_size * torch.sign(load_diff)
Removing the auxiliary balancing loss avoids one source of gradient interference. It is one contributor among data, scale, architecture, optimization, and post-training—not a causal explanation by itself for the final benchmark scores.
5. GLM-5.2: MoE Becomes a Full Agent Pipeline
GLM-5.2 is a useful 2026 case because its improvement is not confined to the router. The released MIT configuration describes 753B parameters, 78 layers, three initial dense layers, then 256 routed experts plus one shared expert with eight routed experts selected per token [5] [6].
Its long-context path uses DeepSeek Sparse Attention with IndexShare: one sparse indexer is reused across each four-layer group. The model retains layer-specific attention computation while amortizing the expensive decision about which historical positions to retrieve. This turns sparse attention from a paper-level asymptotic claim into a serving design.
The MTP path was co-designed with inference. Z.ai reports IndexShare/KVShare, rejection sampling, and an end-to-end total-variation objective that move average accepted speculative length from 4.56 to 5.47 tokens. Its serving stack also describes layer splitting, memory management, long-context kernels, a cache pipeline, and CPU scheduler paths [5]. A model architecture can enable speculative decoding, but the systems layer decides whether that draft acceptance becomes user-visible latency.
Post-training targets long-horizon agents directly. Parallel on-policy distillation merges more than ten expert policies; critic-based PPO trains on compacted long trajectories; token-level loss avoids letting short samples dominate; and an anti-hacking filter first applies rules and then an LLM judge. Blocked suspicious tool calls return dummy results so the rollout must recover rather than disappear from the dataset. This is a rare public example where failure recovery is part of the training distribution.
The data disclosure boundary is just as important: the launch materials describe post-training machinery in detail, but not the full pre-training corpus mixture and filtering recipe. “Open weight” makes architecture inspection and deployment possible; it does not automatically make the entire training pipeline reproducible.
6. Architectural Comparison
To synthesize the differences, let’s look at a comparative matrix of these models alongside a dense baseline (Llama-3 70B).
| Model | Architecture Type | Total Params | Active Params | Experts () | Top-K () | Routing Strategy |
|---|---|---|---|---|---|---|
| Llama-3 70B | Dense | 70B | 70B | N/A | N/A | N/A |
| Mixtral 8x7B | Coarse MoE | 47B | 13B | 8 | 2 | Standard Softmax |
| DBRX | Fine-Grained MoE | 132B | 36B | 16 | 4 | Dropless (MegaBlocks) |
| Grok-1 | Coarse MoE | 314B | not reported here | 8 | 2 | Standard Softmax |
| DeepSeek-V3 | Ultra-Fine MoE | 671B | 37B | 256 (+1 shared) | 8 | Aux-Loss-Free Bias |
| GLM-5.2 | Long-context MoE | 753B | Not disclosed in cited config | 256 (+1 shared) | 8 | Aux-Loss-Free + IndexShare |
Observation: The industry trend is clear. Models are moving from coarse-grained experts (8 choose 2) toward extreme fine-grained sparsity (256 choose 8). Total parameter counts are skyrocketing to capture world knowledge, while active parameter counts are tightly constrained to maintain inference speed and batch processing efficiency.
October Case: Active Compute Depends on Serving Phase
As of 2026-10-13. DeepSeek V4.1 Flash’s report describes 552B backbone parameters, with 8B active during prefill and 16B during decode, using its Causal Encoder-Decoder [7]. This illustrates why a single “active parameters” column is insufficient for input-heavy agents.
Measure prompt processing and output generation separately, including expert dispatch, shared components, compressed-cache work, lookup memory, and communication. Neither expert selection ratio nor active parameters alone determines FLOPs, HBM capacity, or latency. Storage still has to accommodate the deployment’s required weights and states. Compare complete workloads at fixed quality and latency targets; an architecture can save prefill work while leaving another bottleneck dominant.
7. Summary & Next Steps
The evolution of MoE architectures from Mixtral to DeepSeek-V3 demonstrates that scaling intelligence is no longer just about stacking more layers; it is about routing efficiency and sparsity. We have seen how fine-grained experts increase combinatorial capacity, how dropless routing maximizes hardware utilization, and how auxiliary-loss-free strategies protect the purity of the learning signal.
However, designing the architecture is only half the battle. Training a 671B parameter model with 256 experts introduces catastrophic system-level challenges. How do we feed 15 trillion tokens into these models without the GPUs idling? How do we handle the massive cross-node communication overhead when tokens need to be sent to experts residing on entirely different servers?
In the next chapter, Chapter 6: Foundation Model Pre-training, we will descend into the infrastructure layer. We will explore the massive data engineering pipelines, the tokenization science, and the extreme networking (NVLink/InfiniBand) required to keep these sparse leviathans fed and stable during months of continuous training.
Quizzes
Quiz 1: Why is Mixtral 8x7B’s total parameter count 47B instead of 56B?
Mixtral does not replicate the entire 7B model eight times. Only the FFN layers are duplicated across the experts, while the attention weights and token embeddings remain shared. Because the FFN accounts for a large share of a dense Transformer’s parameters, repeating only that part yields roughly 47B total parameters rather than 56B.
Quiz 2: What is the primary advantage of DBRX’s routing configuration?
DBRX offers many more possible unordered expert subsets through finer-grained routing. That provides flexibility, but combinatorial counts alone do not prove quality or equal active compute across different models.
Quiz 3: What does DeepSeek-V3’s dynamic selection bias change, and what does it not guarantee?
Dynamic non-gradient biases influence selection, while mixture weights use original affinities. This avoids adding that controller as a differentiable task penalty, but dispatch and learned gradients still change. V3 also keeps a small sequence-wise auxiliary term.
Quiz 4: What happens when an expert exceeds its capacity factor, and how does MegaBlocks fix it?
In traditional MoE implementations, static tensor shapes are required for efficient GPU execution. When an expert exceeds its capacity, the extra tokens are dropped and bypass the FFN entirely, which hurts quality. If an expert receives too few tokens, the unused slots are padded, wasting compute. MegaBlocks replaces that rigid scheme with block-sparse matrix multiplications so the computation blocks match the routed tokens exactly, avoiding both dropping and padding.
References
- Jiang, A. Q., et al. (2024). Mixtral of Experts. arXiv preprint. arXiv:2401.04088.
- Gale, T., et al. (2022). MegaBlocks: Efficient Sparse Training with Mixture-of-Experts. arXiv preprint. arXiv:2211.15841.
- xAI. (2024). “Open Release of Grok-1.” “xAI Blog”. Link.
- DeepSeek-AI. (2024). DeepSeek-V3 Technical Report. arXiv preprint. arXiv:2412.19437.
- Z.ai. (2026). GLM-5.2: From Long Context to Long-Horizon Agents. Z.ai.
- Z.ai. (2026). GLM-5.2 model card and configuration. Hugging Face.
- DeepSeek-AI. (2026). DeepSeek-V4.1-Flash: Pushing the Limits of KV Cache Compression. Source.
- Databricks (2024). Introducing DBRX.