Abstract / TL;DR Reinforcement Learning (RL) has become a cornerstone for unlocking the advanced reasoning capabilities of Large Language Models (LLMs). However, applying RL to Mixture-of-Experts (MoE) architectures is notoriously unstable, frequently resulting in total training collapse. This paper identifies the root cause as a discrepancy between inference and training routing behaviors, and introduces Rollout Routing Replay (R3). By recording expert selection decisions during inference and "replaying" them during training, R3 ensures the model optimizes the exact experts it used to generate responses, stabilizing training and significantly boosting performance.
The Challenge: Training-Inference Discrepancy
Mixture-of-Experts (MoE) models—such as Mixtral and DeepSeek—are highly favored in modern AI because they scale parameter counts massively while keeping computational costs low. They achieve this by using a "router" that directs each token to a small, specialized subset of "experts."
However, fine-tuning these models via RL introduces a critical vulnerability. Modern RL pipelines typically utilize separate software engines for inference (sampling responses to collect rewards) and training (calculating gradients and updating weights). Because floating-point operations are non-associative, these different compute kernels yield microscopic numerical variations.
In standard "dense" models, these variations are negligible due to functional continuity. But in MoE models, the router relies on a Top-K operation, which acts as a discrete switch. A microscopic numerical nudge can cause the router to select Expert A during inference but Expert B during training. This discontinuity amplifies tiny errors into massive gradient noise and policy divergence, ultimately causing the model's performance to collapse entirely.
The Solution: Rollout Routing Replay (R3)
To bridge this gap, the authors propose Rollout Routing Replay (R3), a structural fix that aligns the training and inference phases through two primary steps:
- Record (Inference Phase): During the "rollout" phase, as the model generates answers to collect rewards, the inference engine saves a routing mask. This mask is an exact record of which experts were selected for every single token.
- Replay (Training Phase): During the weight-update phase, the training engine is forced to use this recorded mask. Instead of recalculating expert assignments, it simply reloads the historical selections.
Crucially, while the selection of experts is fixed by the mask, the gating weights (the relative importance assigned to each expert) are still computed using the training engine's logits. This ensures that gradients continue to flow smoothly through the router, allowing the model to refine its routing logic without the catastrophic instability of mid-stream expert switching.
Experimental Setup and Key Results
The researchers evaluated R3 on verifiable reasoning tasks, specifically mathematics and software engineering, using the Qwen3-30B-A3B (MoE) and DeepSeek-V2-Lite model families. Training utilized ~100,000 math problems (from BigMath and ORZ) and R2E-Gym-Lite for code, with evaluations on standard benchmarks like AIME24/25, AMC23, MATH500, and SWE-bench.
The results demonstrate that R3 is highly effective:
- Preventing Collapse: In baseline scenarios where standard GRPO (Group Relative Policy Optimization) training collapsed to near-zero performance, R3 maintained perfect stability.
- Performance Boosts: On the Qwen3-30B-A3B-SFT model, integrating R3 improved the average math validation score from 62.23 to 71.83. In software engineering (SWE-bench Verified), R3 boosted the GRPO baseline score from 31.80 to 38.60.
- Reduced Divergence: R3 cut the KL divergence between training and inference policies by approximately half, bringing the stability of MoE models in line with that of dense models.
Key Insights and Efficiency
- Orthogonality: R3 is not a replacement for RL algorithms like PPO or GRPO; it is an orthogonal, structural enhancement. It can and should be combined with other stability techniques like KL-clipping or Importance Sampling.
- High Efficiency: Storing every routing decision might sound resource-intensive, but routing masks are tiny compared to KV caches. By storing these masks in CPU memory and transferring them to the GPU only when necessary, the authors achieved robust stability with a mere 3.45% throughput penalty.
Limitations and Future Directions
While R3 offers a robust solution to MoE RL instability, the authors note a few areas for future exploration:
- Memory Management: The ~2.5GB CPU memory overhead is manageable for current setups but could become a bottleneck for extremely long context windows or massive batch sizes in memory-constrained environments.
- Task Scope: The evaluation focuses heavily on verifiable tasks (math and coding). It remains an open question whether R3 provides similar benefits for subjective RLHF tasks (e.g., creative writing), where routing might be less sensitive to exact expert matching.
- Framework Integration: R3 currently requires custom engineering to pass routing masks between distinct engines (like SGLang and Megatron). Standardizing a "routing metadata" format across the open-source ecosystem would greatly accelerate its adoption.
Summary updated