Pick a concrete input and say what the equation should give before you read the math.
Foundation reference
Mixture-of-Depths
Mixture-of-depths (MoD) uses a learned router to send selected tokens through a transformer block while the other tokens skip it. MoD models matched baseline transformers trained with the same FLOPs and wall-clock time while needing only a fraction of the FLOPs per forward pass, and were upwards of 50% faster per step when sampling (Raposo et al., 2024).
Study guide
Where to start
Which tokens would you expect the router to send through a block, and which to let skip it?
How to study this pagePredict · Check · Generalize · Continue
Work through the math, then read the cited papers for the original argument.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
Use the prerequisites and related concepts at the end of the page to fill the next gap.
Why It Matters for Modern Models
- Mixture-of-depths (MoD) uses a learned router to send selected tokens through a transformer block while the other tokens skip it. MoD models matched baseline transformers trained with the same FLOPs and wall-clock time while needing only a fraction of the FLOPs per forward pass, and were upwards of 50% faster per step when sampling (Raposo et al., 2024).
- It is related to mixture-of-experts: both use learned top-k routing, but MoE chooses which expert processes a token, while MoD chooses whether a block processes it at all.
- Unlike earlier adaptive-computation schemes, in which the amount of computation varies with the input (Graves, 2016), MoD fixes the total compute per block in advance, which keeps the computation graph static and the cost predictable.
Questions to Think About
- Why does multiplying the block output by the router weight matter for training, when the top-k choice itself is not differentiable?
- Why is choosing the top k tokens over a whole sequence a problem for generating text one token at a time, and how does predicting the choice get around it?
Core Math
Mixture-of-depths (MoD) lets each block of a transformer process only some of the tokens in a sequence; the others skip the block through the residual connection (Raposo et al., 2024).
At block , a learned router gives each of the tokens a scalar weight . Only the tokens with the largest weights, the set , go through the block's attention and MLP, written . Let be the selected token sequence; is its output at selected position :
Multiplying the block output by puts the router on the gradient path, so it can be trained by ordinary backpropagation.
Because is fixed in advance, the compute per block and the tensor shapes are known before the input is seen. With a capacity of on every other block, the setting Raposo et al. found best, 87.5% of tokens skip each routed block.
Choosing the top over a whole sequence looks at future tokens, which are not available when generating one token at a time. Raposo et al. therefore train either the router itself, with an auxiliary loss, or a small separate predictor to guess whether each token would have been in the top , and use that guess during sampling.