FoundationsChecking saved investigationReading browser-local route memory before showing a continuation.

Foundation Lab

Mixture-of-Depths

Adaptive compute: "think harder" only when needed

Concept 95 of 100EfficiencyPhase 13
#95MoDEfficiency
key equationh^{\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}

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

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 the demo.

Ask what should change when the equation is manipulated, then let the visualization test that expectation.

EvidenceCompare local witness and source.

Use the runnable panel, the key equation, and canonical papers as separate forms of evidence for the same object.

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)

Interactive Visualization

Core Math (Optional Deep Dive)

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

Key Equation
ht+1=Block(ht)1tS+ht1tSh^{\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)tShtotherwiseh^{\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.