Foundation Lab

Mixture-of-Depths

Adaptive compute: "think harder" only when needed

Concept 95 of 100EfficiencyPhase 13
#95MoDEfficiency
key equation
htℓ+1=Blockℓ(htℓ)⋅1t∈Sℓ+htℓ⋅1t∉Sℓh^{\ell+1}_t = \text{Block}_\ell(h^\ell_t) \cdot \mathbf{1}_{t \in S_\ell} + h^\ell_t \cdot \mathbf{1}_{t \notin S_\ell}
Reading map and next steps

Selected Foundation Object

Keep the equation fixed; move through the evidence.

Concept 95 of 100MoDEfficiency / Phase 13: Cutting-edge 2024-2025 research
Current question

Some tokens need deep processing, others can skip layers

htℓ+1=Blockℓ(htℓ)⋅1t∈Sℓ+htℓ⋅1t∉Sℓh^{\ell+1}_t = \text{Block}_\ell(h^\ell_t) \cdot \mathbf{1}_{t \in S_\ell} + h^\ell_t \cdot \mathbf{1}_{t \notin S_\ell}
PredictionCommit before tracing the equation.

Ask what should change under a concrete input, then trace that expectation through the equation.

EvidenceCompare the equation and source.

Use the key equation and canonical papers as the available witnesses, without implying that a runnable panel exists.

InvariantName what survives notation changes.

The useful learning product is the reusable mechanism you can carry into another model, paper, or engineering tradeoff.

Next moveContinue through the atlas.

Use prerequisites, dependents, and semantic links to repair the next gap without leaving the object behind.

Why It Matters for Modern Models

  • Adaptive compute: "think harder" only when needed
  • Like MoE but routing tokens to layers, not experts
  • Predictable FLOPs budget enables efficient deployment

What Tutorials Skip

What is still poorly explained in textbooks and papers:

  • Some tokens need deep processing, others can skip layers
  • Router learns which tokens are "important"
  • Complement to MoE: sparse width (MoE) + sparse depth (MoD)

Visualization Status

Core Math (Optional Deep Dive)

If you want intuition first, start with the key equation and cited sources. Come back here for the full walkthrough.

Key Equation
htℓ+1=Blockℓ(htℓ)⋅1t∈Sℓ+htℓ⋅1t∉Sℓh^{\ell+1}_t = \text{Block}_\ell(h^\ell_t) \cdot \mathbf{1}_{t \in S_\ell} + h^\ell_t \cdot \mathbf{1}_{t \notin S_\ell}

Route tokens to different depths. At layer ℓ\ell, score gℓ(t)g_\ell(t) per token:

Sℓ=TopK({gℓ(t)}t=1n,k)S_\ell = \text{TopK}(\{g_\ell(t)\}_{t=1}^n, k)
htℓ+1={Blockℓ(htℓ)t∈Sℓhtℓotherwiseh^{\ell+1}_t = \begin{cases} \text{Block}_\ell(h^\ell_t) & t \in S_\ell \\ h^\ell_t & \text{otherwise} \end{cases}

Train with explicit compute constraint kk (predictable FLOPs).

Canonical Papers

Mixture-of-Depths: Dynamically allocating compute in transformer-based language models

Raposo et al.2024arXiv
Read paper →

Connections

Prerequisites

Next Moves

Choose the next question to carry this object forward.