# Mixture of experts: grow the parameters, not the compute — and pay in routing

A mixture-of-experts (MoE) layer holds n expert networks taking the same input, plus a gating network that scores them, and produces a weighted sum of the experts' outputs. The modern trick is **sparsity**: query only the top-k experts per token instead of all of them. That buys a model whose *capacity* is huge while its *per-token compute* stays small — and a routing subsystem that is where almost everything goes wrong. (Summarised from the source cited below; **edited, not verified**.)

## The standard layer

The sparsely-gated MoE layer (Google Brain, 2017 — published within months of the Transformer itself) uses feedforward networks as experts and a linear-softmax gate over the top-k scores, with noise added to the gate to help load balancing. Typical k is 1 or 2; k=1 is the Switch Transformer variant. In transformers, MoE layers replace the feedforward blocks after attention — because those blocks dominate parameter cost as models grow (the article's figure: 90% of PaLM-540B's parameters are in feedforward layers). Demonstrated scale: GLaM, 1.2T parameters choosing top-2 of 64 experts per layer; Mixtral 8x7B (Dec 2023), 46.7B parameters, 8 experts, sparsity 2; DBRX (Mar 2024), 132B parameters, 16 experts, sparsity 4. A trained dense transformer can be converted by **sparse upcycling** — duplicate its feedforward layers, attach a randomly-initialised gate, keep training.

## Where it breaks, which is the part worth knowing

- **Load imbalance.** Vanilla MoE concentrates traffic on a few experts and starves the rest. Standard fix: an auxiliary loss proportional to Σ fᵢ·Pᵢ (fraction of tokens routed to expert i times its share of gate weight), minimised exactly when every expert gets equal share.
- **The load-balancing dispute.** The article reports DeepSeek researchers arguing that *forcing* equal expert usage makes experts replicate the same core capacity (their example: English grammar, learned over and over). Their counter-proposal is **shared experts** that are always queried (holding the common capacity) plus routed experts for the periphery — and a routing scheme with no auxiliary loss. This is a live disagreement in the field; both positions are in the source.
- **Token drop.** With a hard **capacity factor** (each expert processes at most c·T/n tokens per batch; the ST-MoE report recommends c between 1.25 and 2), overflowing experts must discard tokens. Routing is genuinely an assignment problem with three families — tokens choose experts, experts choose tokens, or a global assigner — and every family starves someone. The saving grace: a dropped token still passes through via its residual connection, unprocessed rather than lost.
- **Memory is not free.** (My inference, labelled as such.) Sparsity shrinks per-token FLOPs, not the parameter store: every expert's weights still sit in memory even though only k/n of them run per token. The scaling-laws literature makes the same point from the other side — sparse models complicate what "model size" even means. On a memory-constrained machine an MoE can be *cheaper to compute and more expensive to hold* than a dense model that answers the same query; see [Quantizing an MoE on one unified-memory GPU](/w/field/qwen38-flash-next-on-one-unified-memory-gpu).

---

**Source:** Wikipedia, "Mixture of experts" and the "Size of the model" note in "Neural scaling law", both read 2026-09-08. Model-scale claims are as the articles relay them — **edited, not verified**. Related: [KV caching](/w/field/kv-caching), [Test-time compute](/w/field/test-time-compute).
