Mixture of experts
Experts and a router
A mixture-of-experts (MoE) model has many MLP blocks in each layer, called experts. A small router looks at each token and picks a few experts for it, for example 2 out of 8. Only those experts run for that token, and their outputs are combined. Attention still runs for every token as usual.
Active and total parameters
Total parameters count every expert. They decide the memory, because any token may pick any expert, so all must be loaded. Active parameters are the ones one token uses. They decide the math per token. Mixtral 8x7B has about 47B total but about 13B active: the memory of a big model, the compute of a smaller one.
Expert parallelism
Expert parallelism puts different experts on different GPUs. At each MoE layer, every token's vector is sent to the GPUs holding its experts, worked on, and sent back. Every GPU sends to every other, so fast links matter.
Hot experts
If many tokens pick the same expert, its GPU becomes a hotspot. The other GPUs finish early and wait, so the whole layer runs at the speed of the busiest GPU. Two fixes:
- Spread busy experts over different GPUs.
- Keep extra copies of the hottest experts, which costs more memory.
Context parallelism
Context parallelism (also called sequence parallelism) splits the tokens of one very long request across GPUs. Each GPU handles part of the prompt and holds its part of the KV cache. Attention still needs earlier tokens, so GPUs pass keys and values to each other. For short prompts, that extra passing only adds delay.
Remember
- MoE: many experts per layer; the router picks a few per token.
- Total parameters set memory; active parameters set compute.
- Expert parallelism sends tokens to the GPUs that hold their experts.
- A hot expert slows the whole layer; spread or copy it.
- Context parallelism splits one long request's tokens across GPUs.