Vibe Engines
YouTube
Paper 10~7 min readShazeer et al. · 2017
Paper Breakdown

Mixture of Experts,
explained.

A hospital doesn't send every patient to every doctor — a receptionist points each one to the right specialist. This idea, applied to neural networks, is why a model can carry hundreds of billions of parameters yet stay cheap to run: for any given token, almost all of it stays asleep.

The delta

What changes here: size stops implying cost

Rung 1, so the comparison is against the dense network every other ladder assumes. In a dense model, every parameter participates in every token's computation. That means the two things you most want to separate are welded together: to give the model more capacity you must also make every forward pass more expensive, for training and for every request you ever serve.

The change is conditional computation. Replace one large feed-forward layer with many expert sub-networks plus a small gating network that reads each token and selects a few experts to handle it. Only the selected experts run. Total parameter count can then grow by a large factor while the arithmetic per token stays roughly flat — the model is enormous in storage and ordinary in cost, and capacity and compute are decoupled.

Two failure modes are inherent to that design and both are addressed here, because neither is optional. The first is collapse: the gate has every incentive to converge on a few experts, since the experts it picks get trained and improve, so the rest stay bad and are never picked. The fix is an auxiliary loss that penalises unbalanced routing, plus noise in the gate so alternatives get sampled. The second is the shrinking batch: if a batch of tokens is split across many experts, each expert sees only a sliver, and the matrix multiplications that hardware is fast at become small and inefficient. Both are consequences of sparsity rather than bugs in this implementation, and both reappear in every rung above.

01

The dense-model tax

In a normal dense network, every parameter is used for every input. That's a hard tax: to make the model twice as capable you double the parameters, and now every single token costs twice as much compute. Capacity and cost are chained together, so scaling up gets expensive fast.

But intuitively, that's wasteful. A token about French poetry and a token about Python syntax probably don't need the same billions of parameters. What if different parts of the model handled different kinds of input?

02

The idea: many specialists, one receptionist

A Mixture of Experts replaces one big dense layer with many smaller sub-networks — the experts — plus a small gating network that acts as a receptionist. For each token, the gate picks just the top one or two experts to handle it. The rest sit idle for that token.

So the model can have dozens or hundreds of experts — an enormous total parameter count — while any single token only ever touches a couple of them. This is sparse activation: lots of capacity, little compute per token.

03

The gating network

The gate is itself learned. For each token it scores every expert, keeps the highest few (top-k routing, often k=1 or 2), and sends the token only to those. Their outputs are blended, weighted by the gate's scores. Over training, the gate discovers which experts are good at what and routes accordingly.

Top-2 routing for one token
token
↓
gating network — picks top 2
↓
Expert 1 ● Expert 2 Expert 3 ● Expert 4 … Expert N

Only the two lit experts run. The other N−2 — the bulk of the model's parameters — cost nothing for this token.

04

The catch: load balancing

Left to its own devices, the gate cheats. It finds a few experts that work well early on and keeps sending everything to them, while most experts starve — never getting enough tokens to learn anything. A model with 128 experts that only ever uses 4 is mostly dead weight.

Worth knowing

The fix is an auxiliary load-balancing loss that penalizes lopsided routing and nudges the gate to spread tokens across all experts. Getting this balance right is one of the central engineering challenges of training MoE models.

05

Sparse vs dense

The original Sparsely-Gated MoE built layers with up to thousands of experts and billions of parameters, beating strong dense baselines at a fraction of the compute. The later Switch Transformer simplified routing to a single expert per token and scaled to over a trillion parameters — while keeping per-token cost roughly flat.

Total parametersActive per tokenCompute per token
Dense modelNAll NGrows with N
MoE modelMany × NOnly top-k experts~Constant

The chain between capacity and cost — the thing that made scaling expensive — is broken. And it's two formulas, not a metaphor. Store every expert, but run only k of the E per token:

The only difference is E vs k — capacity scales with the expert count you store, compute scales with the few you fire. Plug in a Mixtral-8×7B-shaped config (d=4096, 32 layers, 8 experts, top-2):

Eightfold the capacity, identical per-token compute — the whole point of conditional computation, in two numbers.

06

Why it still matters

Mixture of Experts is one of the main levers behind the frontier. Open models like Mixtral and DeepSeek are MoE, and several leading proprietary models are widely believed to be as well. When you hear a model has "hundreds of billions of parameters" but runs surprisingly cheaply, MoE is usually why — only a slice of it wakes up for each token.

The deeper idea — conditional computation, spending compute only where it's needed — is one of the most powerful tools we have for scaling models without scaling their bills. This paper is where it went from theory to practice.

Since then

What the authors admit, and what happened next

The paper is direct about the costs sparsity introduces: routing tokens to experts that live on different devices is a communication problem, so the gains are contingent on the interconnect, and the auxiliary balancing loss is a term that is explicitly fighting the objective you actually care about — it exists to keep the mechanism healthy, not to make the model better at language.

One belief it establishes was later overturned. Routing to at least two experts was argued to be necessary for the gate to receive a useful learning signal, on the reasoning that you need to compare alternatives to know a choice was good. Rung 2 shows a single expert per token works, which removes roughly half the cost and most of the complexity.

How it held up: it is the architectural basis of the current frontier. The models at the top of this ladder and several on the open-weights ladder are mixtures of experts, and the reason is exactly the decoupling above — it is the only known way to buy capacity without buying proportional serving cost. What has been revised is every mechanism: top-1 replaced top-k, and rung 3 removes the auxiliary loss itself in favour of something that does not compete with the language objective.

SOLVE IT YOURSELF

Count the parameters that actually fire

"Hundreds of billions of parameters but runs cheap" is a claim you can verify with multiplication. This computes a Mixtral-8×7B-shaped model's total parameters (capacity) and active parameters per token (compute) from first principles — and lands on the real ~47B / ~13B. Then crank the expert count to 64 and watch total explode past 360B while active never budges off 13B. That flat column is conditional computation; capacity and cost, finally unchained. Change E, k, or the dimensions.

YOUR TASK

Write the body of active_params. Everything else in the file is already written; this is the function the paper is about. Press ▶ Run to check it against the 5 assertions below — they start red.

WHAT IT HAS TO SATISFY — 5 ASSERTIONS
  1. Storing more experts raises total capacity
  2. Active params depend on top-k, not the expert count
  3. Only a fraction of the model fires per token
  4. Adding experts raises capacity but not per-token compute
  5. A Mixtral-shaped config lands near 47B total / 13B active
CPython · WebAssembly
07

Why it still matters

Mixture-of-Experts answers a specific bind: you want a model with more parameters (more capacity to know things) without paying more compute per token. MoE does it by replacing a dense feed-forward layer with many expert sub-networks and a router that sends each token to just a few of them. The model can be huge in total parameters while only a small slice activates per token — capacity without proportional cost.

The number that matters is active vs total parameters. A model might hold, say, 600B parameters but activate only ~37B per token; it pays roughly the inference cost of a 37B model while carrying the knowledge of something far larger. That decoupling is why several frontier-class models are MoE under the hood — it is one of the main ways labs push capability up while keeping serving affordable.

The catch is that MoE buys cheaper compute, not cheaper memory: every expert's weights must still be loaded, so the full parameter count sits in VRAM even though most of it is idle each step. MoE trades memory for compute — great when you are compute- or latency-bound, less helpful when memory is the wall.

The hard part in practice is the router. If it sends too many tokens to a few favorite experts, the rest sit unused and capacity is wasted, so training needs load-balancing pressure to keep experts evenly fed. Getting routing stable and balanced — rather than the expert idea itself — is where much of the real engineering goes, and it is why MoE was tricky to train well for years before it became mainstream.

Check yourself

5 questions on this paper

Answer each one out loud before you open it. Recalling an answer is what makes it stick; recognising one you have just read is not. Your score is kept on this device.

What is a Mixture of Experts (MoE)?

Show answer

A Mixture of Experts is a neural-network layer made of many parallel sub-networks called experts, plus a small gating network that decides, for each input token, which one or two experts should handle it. Because only a few experts run per token, the model can hold an enormous total number of parameters while doing only a small, fixed amount of computation for each token.

How does MoE make models bigger without making them slower?

Show answer

In a dense model, every parameter is used for every token, so more parameters means more compute per token. MoE breaks that link: it adds many experts (lots of parameters) but routes each token to only a couple of them. Total capacity grows, but compute per token stays roughly constant — you get a much larger model at nearly the same inference cost.

What is the gating network in MoE?

Show answer

The gating network is a small learned router. For each token it produces scores over all the experts and selects the top-k highest (often just the top 1 or 2). The token is sent only to those experts, and their outputs are combined, weighted by the gate's scores. The gate learns which experts specialize in which kinds of input.

What is load balancing in MoE?

Show answer

Left alone, the gate tends to favor a few popular experts and starve the rest, wasting capacity. MoE training adds an auxiliary load-balancing loss that encourages the router to spread tokens more evenly across all experts, so every expert gets used and learns something useful.

Which models use Mixture of Experts?

Show answer

MoE went from the Sparsely-Gated MoE layer (2017) to the Switch Transformer, and now underpins many frontier models — open models like Mixtral and DeepSeek use MoE, and several leading proprietary models are widely believed to as well. It's a standard tool for scaling parameter count efficiently.

Where this sits

One model, many experts

Sparsity: route each token to a few experts and buy parameter count without paying for it at inference. 2017 idea, 2026 frontier default.

  1. 1Mixture of Experts2017
  2. 2Switch Transformer2022
  3. 3DeepSeek-V32024
  4. 4DeepSeek-V42026
  5. 5Qwen4-Coder2026

All 110 papers, in 19 ladders →

Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer · Shazeer, Mirhoseini, Maziarz, Davis, Le, Hinton, Dean · 2017 · read the original paper on arXiv → · Vibe Engines · 2026
▶  Watch it explained

Prefer a video walkthrough?

Finished this one? 0 / 110 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns