Home Knowledge Base Mixture of Depths (MoD)

Mixture of Depths (MoD) is the dynamic computation technique for transformers that allows individual tokens to skip certain transformer layers — allocating compute resources proportionally to token "difficulty" rather than uniformly processing every token through every layer, achieving 50% compute reduction with minimal quality loss by routing easy tokens (function words, whitespace, common patterns) through fewer layers while hard tokens (rare words, complex reasoning steps) receive full depth processing.

Motivation: Uniform Compute is Wasteful

MoD Mechanism

For each layer l:
  router_scores = linear(token_embedding)  # scalar per token
  top_k_mask = topk(router_scores, k=S*C)  # select capacity C fraction
  
  full_tokens = tokens[top_k_mask]          # process these through attention+FFN
  skip_tokens = tokens[~top_k_mask]         # bypass via residual
  
  output = combine(processed_full, skip_tokens_unchanged)

Capacity and Routing

Results (Raposo et al., 2024)

What Gets Skipped?

Comparison with Related Methods

MethodWhat RoutesSavings
MoEWhich expert (same depth)Width compute
MoDWhich depth (same width)Depth compute
Early ExitStop at intermediate layerTrailing layers
Adaptive SpanAttention span per headAttention compute

Practical Challenges

Mixture of Depths is the principled answer to the observation that transformers waste enormous compute treating all tokens equally — by learning to allocate depth proportional to token complexity, MoD achieves the theoretical ideal of adaptive compute allocation in an end-to-end differentiable framework, pointing toward a future where transformer inference cost is proportional to content complexity rather than sequence length, making long-context reasoning dramatically more efficient without architectural changes.

mixture of depthsadaptive computationtoken routingdynamic depthearly exit routing transformer

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.