CURRICULUMMIXTURE OF EXPERTS, FROM ZERO01

What a mixture-of-experts model is

A dense transformer runs every parameter on every token. A sparse one keeps most of its parameters idle for any given token and lets a small router decide which few to wake. Everything else in this track follows from that one change.

Reading time
6 min
Words
1,351
Sources cited
8
Updated
2026-11-02
Prerequisites
None

Start with the layer that costs the most

A transformer is a stack of identical blocks. Each block does two things to every token: attention, which lets the token read the other tokens in the sequence, and a feed-forward network, which transforms the token on its own. The feed-forward network is two or three large matrices. In a dense model every token is multiplied through every one of them, in every block, on every step.

Those matrices are where the parameters live. In the model this track uses throughout, Qwen3-30B-A3B, the tensors that make up the feed-forward experts account for 57,982,058,496 of the artifact's 61,064,245,248 bytes — 95.0% — counted from the safetensors shard headers committed in this repository. Attention, embeddings, norms and the router share the remaining 5%.

So if you want a model with far more parameters at the same cost per token, the feed-forward layer is the place to intervene.

Replace one feed-forward network with many, and choose

The idea, in the form that survives today, was introduced for neural language models in 2017: build the layer from a large set of feed-forward sub-networks — up to thousands — and put a small trainable gating network in front of them that picks a sparse combination for each input. The sub-networks are the experts. The gating network is the router. The number of experts the router keeps per token is k, and the whole arrangement is called top-k routing.

Qwen3-30B-A3B is a concrete instance, and its config.json says exactly how. num_experts is 128 and num_experts_per_tok is 8: in each block the router scores all 128 experts, keeps the 8 highest, runs the token through those 8 and sums their outputs weighted by the router's scores. norm_topk_prob is true, so the 8 weights are renormalised to sum to one. decoder_sparse_step is 1, so every one of the 48 blocks is a mixture-of-experts block. Each expert is a narrow feed-forward network: moe_intermediate_size is 768 against a hidden_size of 2048.

Nothing about the token's path through attention changes. The sparsity is confined to the feed-forward layer, which is why a mixture-of-experts model is best thought of as a dense model with one layer type swapped out, not as a different kind of network.

Total and active are two different counts

The model card for Qwen3-30B-A3B states 30.5B parameters in total and 3.3B activated. The name encodes both: 30B total, A3B active. The total is every parameter in the checkpoint, which is what you must store. The active count is the parameters one token actually passes through — attention, the router, the 8 chosen experts, and the dense remainder — which is what sets the arithmetic per token.

The ratio is 3.3 ÷ 30.5 = 0.108, so a token touches about 11% of the model. Notice that this is not 8 ÷ 128 = 6.25%. The difference is everything that is not an expert: attention and embeddings run on every token regardless of routing, so the active fraction never falls to the routed fraction. Track 02 of this curriculum works through what that means for memory; here it is enough to see that the two counts answer different questions.

Mixtral 8x7B makes the same point with rounder numbers. Each layer has 8 experts and the router selects 2 per token; the paper describes each token as having access to 47B parameters while using 13B, and Mistral's release post gives the more precise 46.7B total and 12.9B per token.

Where the idea came from

Three papers carry most of the lineage. Shazeer and colleagues (2017) introduced the sparsely-gated mixture-of-experts layer for language modelling and machine translation, with the trainable gating network described above. GShard (Lepikhin et al., 2020) scaled the approach to a 600-billion-parameter multilingual translation model trained on 2048 TPU v3 accelerators in four days, using top-2 gating — each token dispatched to at most two experts — and an expert capacity that caps how many tokens any one expert may take in a batch.

Switch Transformer (Fedus, Zoph and Shazeer, 2021) then made the simplification that most modern designs inherit: route each token to only a single expert, k = 1. The authors report that this preserved quality, reduced routing computation, and let them pre-train models up to a trillion parameters, with up to 7× faster pre-training than T5 at the same compute and a 4× speedup over T5-XXL at the trillion-parameter scale.

The k in top-k has drifted since. Mixtral uses 2, Qwen3-30B-A3B and DeepSeek-V3 use 8, gpt-oss uses 4. Larger k against a larger pool of smaller experts is the direction the field has moved, and it is the reason expert counts in the hundreds are now ordinary.

Keeping the experts busy: the load-balancing loss

A router left to itself tends to collapse: a few experts get good early, attract more tokens, train faster and attract still more, until most of the pool is idle. Switch Transformer's remedy, inherited from the earlier papers, is an auxiliary loss added to the training objective. For N experts and a batch of T tokens, let f_i be the fraction of tokens dispatched to expert i and P_i the fraction of total router probability assigned to expert i. The loss is α · N · Σ f_i · P_i. It is minimised when both vectors are uniform at 1/N, the factor N keeps it constant as the expert count changes, and the paper uses α = 10⁻², large enough to balance load and small enough not to disturb the language-modelling objective. DeepSeek-V3 later showed that balance can be achieved without an auxiliary loss at all, on the argument that the loss buys balance at some cost to quality; Track 02 covers that trade.

Shared experts

One refinement matters for everything downstream. DeepSeekMoE (Dai et al., 2024) proposed cutting experts finer — mN experts with mK active instead of N with K — and isolating a few of them as shared experts that every token passes through, to capture common knowledge and reduce redundancy among the routed experts.

DeepSeek-V3 carries this into its released configuration: n_routed_experts is 256, n_shared_experts is 1, and num_experts_per_tok is 8, inside a model of 671B total and 37B activated parameters. The shared expert is dense by construction. It is read on every token, so for serving it belongs with attention, not with the routed pool.

Five open-weight mixtures, side by side

The table collects the four numbers that define a mixture-of-experts model as released. Total and active counts come from each publisher's model card or paper; expert counts come from the repository's config.json, named in the sources below. DeepSeek-V3's routed count excludes its one shared expert.

Total parameters, active parameters per token, routed experts per layer and experts selected per token for five open-weight mixture-of-experts releases.
ModelTotalActive per tokenRouted expertsExperts per token
Qwen3-30B-A3B30.5B3.3B1288
Mixtral 8x7B46.7B12.9B82
OLMoE-1B-7B7B1B648
gpt-oss-120b117B5.1B1284
DeepSeek-V3671B37B256 (+1 shared)8

The rule

A mixture-of-experts model is a dense model whose feed-forward layers were replaced by a learned choice among many. Total parameters are what you store. Active parameters are what one token touches. The router is what connects them, and it decides per token, at run time.

Every figure in this lesson is sourced or computed. Where a claim would not verify against its source, it was removed rather than qualified.