---
title: How does a mixture-of-experts layer work, what problems does routing introduce, and how does MoE change the memory…
url: https://gurkanozkan.ai/learn/questions/research-mixture-of-experts-038/
markdown: https://gurkanozkan.ai/learn/questions/research-mixture-of-experts-038.md
kind: question
role: Research
stage: Technical
difficulty: Hard
json: https://gurkanozkan.ai/api/learn/questions/research-mixture-of-experts-038.json
robots: noindex
---

# How does a mixture-of-experts layer work, what problems does routing introduce, and how does MoE change the memory, compute and communication profile compared with a dense model of similar quality?

Research · Technical · Hard

## Answer

*Model answer, written in a candidate's voice*

### In short

- Top-k routing per token: router scores all experts, each token is sent to its top-k experts (commonly k=1 or 2).
- Capacity limits: each expert has a fixed token budget per batch; tokens beyond capacity are dropped or bypass the expert via the residual path.
- Load-balancing auxiliary loss: encourages tokens to spread across experts; without it routing collapses onto a few experts.
- Dropped tokens: overflow tokens lose expert computation, degrading quality, so capacity factor and the auxiliary loss are tuned carefully.
- Memory vs compute: all experts are resident in memory (memory scales with total parameters), while per-token compute scales with active parameters only.
- Expert parallelism: experts are sharded across devices, so routing requires all-to-all communication of tokens and results.
- Router instability: router logits can grow large and destabilise training; a z-loss on router logits is used to keep them bounded.
- Serving implications: high memory footprint and all-to-all traffic, but lower per-token compute; batching, capacity, and load imbalance affect latency and throughput.

### In full

In a mixture-of-experts layer, a small router network scores every expert for each token, and the token is dispatched to its top-k experts (often k=1 or 2), so only a subset of the experts is active per token. Each expert has a fixed capacity per batch, so tokens beyond that limit are dropped or pass through the residual connection, and a load-balancing auxiliary loss is added to push tokens towards underused experts; without it routing collapses onto a few experts, and dropped tokens lose expert computation, which is why capacity factor and the loss are tuned carefully. The key trade-off is that all experts sit in memory, so memory scales with total parameters, while compute per token scales only with the active parameters, letting a model be much larger than its per-token cost. Because experts are sharded across devices in expert parallelism, routing requires all-to-all communication of tokens and outputs, which adds latency and bandwidth pressure. Router logits can also grow large and destabilise training, so a z-loss on the router logits is used to keep them bounded. For serving, this means a large memory footprint and communication overhead in exchange for lower per-token compute, with latency and throughput sensitive to batching, capacity, and load imbalance across experts.

*Corrected by an independent AI reviewer.*

## What a strong answer covers

- Top-k routing per token; capacity limits; a load-balancing auxiliary loss; dropped tokens.
- All experts sit in memory (memory ∝ total parameters), while compute ∝ active parameters.
- Expert parallelism needs all-to-all communication.
- Router instability (z-loss).
- Serving implications.

## Common mistakes

- Claiming MoE cuts memory.
- Ignoring communication cost.

## Topic guides

- [Compute and memory efficiency](https://gurkanozkan.ai/learn/topics/efficiency.md)
- [Distributed training and parallelism](https://gurkanozkan.ai/learn/topics/distributed-training.md)
- [Transformers, attention and scaling](https://gurkanozkan.ai/learn/topics/transformers.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
