TL;DR
Mixture-of-Experts (MoE) models typically collapse if you alter the number of activated experts ($k$) during inference because experts become co-adapted to a fixed team size. Matryoshka MoE (M-MoE) solves this by varying the number of active experts during training—most effectively via independent, layer-wise randomization. The resulting single model supports seamless, elastic inference from $k=1$ to $k=6$, matching the quality of an entire suite of fixed-$k$ specialist models at a fraction of the training cost.
What Problem Does This Paper Address?
Sparse MoE models scale parameter counts efficiently by routing each token to a small subset of experts (Top-$k$). Intuitively, this design should offer elastic inference—allowing users to select fewer experts for fast, low-cost processing, or more experts when high accuracy is needed.
In practice, existing MoE architectures fail dramatically at this. Dialing down $k$ at test time triggers severe performance collapse, while dialing it up yields virtually no improvement. This fragility arises because standard MoE training fixes $k$, causing experts to co-adapt into mutually dependent groups where individual rankings outside the top $k$ are arbitrary and incomplete.
Methods
Inspired by Matryoshka Representation Learning (MRL), the authors introduce Matryoshka MoE (M-MoE) to build a nested, coarse-to-fine functional hierarchy directly into the router and expert ensemble:
- Layer-Wise Stochasticity (M-MoE-layer): Instead of keeping $k$ constant across the network or entire batches, each Transformer layer independently samples an active expert budget $k_l \sim U[k_{\min}, k_{\max}]$ for every forward pass. This forces each layer to handle inputs of varying representational capacity from previous layers.
- Capacity-Aware Weighted Sampling: To account for higher-capacity configurations needing more gradient updates, they formulate a temperature-controlled power-law distribution: $P(k_l = k) \propto k^{1/\tau}$.
- Activation Budget Constraint: To prevent dynamic per-layer expert counts from causing memory fluctuations and training slowdowns, an optional activation budget caps the total active experts across layers per token, redistributing surplus slots to ensure a predictable memory footprint.
Standard Top-k MoE: [Layer 1: k=4] ──> [Layer 2: k=4] ──> [Layer 3: k=4] (Rigid)
M-MoE (Layer-wise): [Layer 1: k=2] ──> [Layer 2: k=6] ──> [Layer 3: k=1] (Elastic)
Datasets
- Pre-training / Continual Pre-training: A diverse corpus mixing public and proprietary data: deduped FineWeb-Edu, deduped DCLM, subsets of Nemotron-CC, synthetic reasoning sets, and code corpora.
- Evaluation Benchmarks: Evaluated in a 5-shot configuration via
lm-evaluation-harnesson 7 standard benchmarks: MMLU, ARC Challenge, BoolQ, HellaSwag, LogiQA, OpenBookQA, and Winogrande.
Key Insights and Ideas
- Hierarchical Inductive Bias vs. Co-Adaptation: Standard MoE treats the $k$-expert ensemble as an indivisible unit, leading experts to learn fragmented sub-tasks. M-MoE forces the Top-1 expert to provide a robust, stand-alone core representation, while subsequent experts learn residual refinements.
- Router Mechanics Truly Replicate Matryoshka Dolls: Using a metric called Focused Spearman Correlation, the authors show that M-MoE maintains consistent expert rankings regardless of budget, whereas standard MoEs produce chaotic rerankings when evaluated away from their native $k$.
- Greater Expert Specialization: Measured via Mean Off-Diagonal Similarity (MODS) of gating vectors, M-MoE experts are significantly more orthogonal to one another, reducing functional redundancy.
- Asymmetric Layer Importance: Layer-wise elasticity reveals that allocating extra compute to earlier layers yields significantly higher performance gains than allocating it to later layers (e.g., an activation pattern of
[3, 3, 2, 2]achieves an average score of 56.41 vs. 56.04 for[2, 2, 3, 3]).
Key Results
- Continual Training (20B MoE, 96 experts):
- A specialist model trained strictly at $k=6$ drops from 57.03 average score down to 45.40 when evaluated at $k=1$.
- A single M-MoE-layer model achieves 54.61 at $k=1$ (beating the $k=1$ specialist baseline of 54.23) and scales smoothly up to 56.72 at $k=6$, all trained under the token budget of a single baseline (80B tokens).
- Throughput Optimization: Implementing the activation budget mechanism reduced peak GPU memory by 10%, enabling a larger micro-batch size and an 8% increase in training throughput with zero degradation in accuracy.
- Training from Scratch (160B tokens): Confirms that elasticity is not an artifact of continual learning; extended training shows consistent monotonic improvements as inference $k$ increases (45.50 at $k=1$ to 46.97 at $k=6$).
Limitations and Future Work
- Early Training Saturation: At early pre-training stages (e.g., 80B tokens from scratch), performance curves across $k$ are relatively flat because training greedily prioritizes top-ranked experts before lower-ranked experts learn useful residual representations.
- Dynamic Routing Overhead: Varying $k$ on a per-layer basis introduces runtime irregularities in distributed environments, requiring balancing mechanisms like activation budgets.
- Initialization Dependency: The continual training experiments initialized from a base model pre-trained at $k=1$; evaluating continual adaptation from existing commercial models trained at fixed $k > 1$ remains to be explored.
Summary updated