Home Knowledge Base A dense transformer wastes compute by treating every token identically.

Mixture-of-Depths (MoD) is a transformer efficiency technique built on a simple observation: a standard transformer spends exactly the same amount of computation on every token, whether that token is a throwaway "the" or a pivotal technical term that the whole prediction hinges on. MoD breaks that uniformity by letting the model choose, at every layer, which tokens are worth the full cost of that layer's attention and feed-forward computation and which can simply skip it and ride the residual connection through unchanged. It is conditional computation along the depth axis of the network — hence the name — and it is the depth-wise cousin of Mixture-of-Experts, which does the same trick along the width axis.\n\nA dense transformer wastes compute by treating every token identically. Every position flows through every block, paying the identical FLOP cost for self-attention and the MLP, regardless of how much processing that position actually needs. But language is not uniform: some tokens are trivially predictable from local context and some require deep, many-layer reasoning. Spending a fixed, maximal budget on all of them means the easy tokens are massively over-served while the compute that could have gone to hard tokens is spread thin. MoD is the attempt to reallocate that fixed budget toward the tokens that need it.\n\nMoD puts a router before each block that admits only the top-k tokens; the rest take the residual shortcut. At every MoD layer a small learned router scores each token, and only the highest-scoring fraction — a fixed capacity, say 12.5% or 50% of the sequence — is passed through the block's attention and MLP. The non-selected tokens bypass the block entirely via the identity residual, arriving at the next layer unchanged. The crucial engineering choice is that the capacity is static: exactly k tokens are processed per block, known ahead of time, so the compute graph has a fixed shape and batches efficiently on a GPU or TPU. This is what separates MoD from classic early-exit / adaptive-depth schemes, where each token dynamically decides when to stop — flexible in theory but a nightmare to batch because different sequences finish at different layers.\n\nMoD, Mixture-of-Experts, and early exit are three different answers to "where do we save compute?" Mixture-of-Experts routes each token to a few of many parallel expert MLPs — it saves compute along width, activating only a sparse slice of a very large parameter count while keeping full depth. MoD routes along depth, keeping the same parameters but letting most tokens skip most layers, cutting FLOPs per token. Early exit varies depth dynamically per token, which maximizes flexibility but sacrifices the static, hardware-friendly shape MoD preserves. Because MoE and MoD save on orthogonal axes, they compose: a "MoDE" block can route across experts and across depth at once, stacking both savings.\n\n| Technique | Saves compute along | Compute shape | Parameters |\n|---|---|---|---|\n| Dense transformer | Nothing — every token, every layer | Static | Fully used |\n| Mixture-of-Experts | Width (parallel experts) | Static, sparse | Many, sparsely activated |\n| Mixture-of-Depths | Depth (skip layers) | Static, fixed capacity | Same as dense |\n| Early exit / adaptive depth | Depth (dynamic per token) | Dynamic, hard to batch | Same as dense |\n\n``svg\n\n \n Mixture-of-Depths: spend compute only where it's needed\n A router admits the top-k tokens into each block's full compute; the rest skip via the residual.\n\n \n \n One MoD layer: router picks top-k, others bypass\n \n tokens in\n \n \n \n \n \n \n router\n score\n \n \n \n \n \n \n attention + MLP\n top-k tokens (full cost)\n \n selected\n \n \n residual shortcut — skipped tokens pass unchanged, no cost\n \n \n \n \n \n \n tokens out\n capacity is FIXED (e.g. 12.5%) → static compute graph → batches efficiently, unlike dynamic early-exit.\n\n \n \n Two axes of conditional computation\n \n Mixture-of-Experts → WIDTH\n route each token to a few of many parallel experts\n full depth · huge sparse parameter count\n saves FLOPs by activating only part of the width\n \n Mixture-of-Depths → DEPTH\n route each token past a subset of layers\n same parameters · fewer FLOPs per token\n they compose → "MoDE" routes width AND depth\n\n``\n\nThe unhelpful way to think about Mixture-of-Depths is as yet another niche efficiency hack layered onto the transformer. The useful way is to see it as answering a question the dense architecture never asks: not how to process a token but whether this token, at this layer, is worth processing at all. By giving every block a router with a fixed capacity, MoD reallocates a constant compute budget toward the tokens that need deep processing and lets the easy ones coast on the residual — capturing much of the benefit of dynamic early-exit while keeping the static, batch-friendly compute shape that hardware demands. Set beside Mixture-of-Experts, which sparsifies the network's width, MoD sparsifies its depth, and the two combine cleanly. Read Mixture-of-Depths through a spend-compute-only-where-it's-needed lens rather than an every-token-deserves-every-layer lens, and the router, the fixed capacity, and the residual shortcut stop looking like tricks and become the natural machinery for buying back the compute a uniform transformer throws away.

mixture of depthsmixture depthsmixture-of-depthsmodconditional compute depthtoken routing depthadaptive layer skippingdynamic depth transformer

Explore 500+ Semiconductor & AI Topics

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