Summary of RoutePack: Expert Placement and Attention-Aware Data Packing for MoE Reinforcement Learning
Summary (Overview)
-
RoutePack is a hierarchical planner that jointly coordinates layer-wise expert placement and attention-aware data packing for Mixture-of-Experts (MoE) reinforcement learning (RL) training, addressing two coupled load-balancing problems: dense attention work in data-parallel (DP) microbatches and sparse expert work in expert-parallel (EP) ranks.
-
The system leverages routing replay from the rollout phase—which reveals each sample's sequence length and layer-wise expert demand before training—to convert data layout from a routing-blind preprocessing step into a load-balancing control.
-
The formulation uses a lexicographic objective that prioritizes (1) the slowest EDP shard over the optimizer-step window, (2) total projected work, and (3) the worst row-local tail, while preserving capacity-efficient row counts.
-
Across Ling-3.0-Tiny (7.9B params) and Ling-3.0-Flash (124B params), RoutePack improves trainer-measured token throughput by 8.85% and 14.89% respectively over baseline, with expert rerouting contributing 3.80%/10.50% and routing-aware packing adding 4.86%/3.98%.
-
The implementation uses layer-wise Longest Processing Time (LPT) placement, state-consistent expert materialization, diverse fixed-row seeding, and parallel population annealing, with a sufficient runtime condition derived for CPU packing to not extend the training-admission critical path.
Introduction and Theoretical Foundation
The Two Coupled Load-Balancing Problems
MoE RL training exposes two distinct sources of load imbalance:
-
Dense attention imbalance: Variable-length RL responses mean that equal sample counts (or even equal packed-token counts) do not imply equal attention work, especially for attention operators with sequence-pair (quadratic) components.
-
Sparse expert imbalance: Token routing determines expert work per EP rank, and the busiest physical rank at each MoE layer paces dispatch and grouped GEMM execution.
The Key Insight: Routing Replay
The rollout and training phases process the same generated token sequence, so routing replay exposes each sample's token length and layer-wise expert demand before the optimizer step is scheduled. For an optimizer-step batch of samples, the planner receives:
where is the sequence length and is the replayed routing count for logical expert at MoE layer .
Why Coordination is Necessary
The paper establishes two critical invariants:
Packing cannot remove optimizer-window expert skew: For a fixed placement , the aggregate demand on physical rank is:
and for any capacity-feasible packing :
Expert placement does not guarantee row-local balance: A placement can make step-wide totals nearly equal while individual rows remain imbalanced due to correlated routing vectors being packed together.
Attention Work Proxy
For attention operator and DP cell , the two-term execution proxy is:
The linear term captures projections and recurrent/linear-attention work; the quadratic term captures token-pair interactions in full attention. KDA and Gated DeltaNet use , while MLA and Gated Attention use .
Methodology
Problem Formulation
Decision variables: Layer-local permutation maps logical experts to physical slots; binary variable indicates sample is assigned to cell at row and DP slot .
Feasibility constraints (rectangular fixed-row):
The minimum feasible row count is .
Hierarchical Planning
Stage 1: Layer-wise expert placement using LPT scheduling. For candidate placement, aggregate physical-rank load is:
where . LPT greedily assigns experts in descending load order to the currently least-loaded physical rank.
Stage 2: Fixed-row data packing with the lexicographic objective:
where is the projected work accumulated by EDP shard , and combines attention and expert costs.
The attention cost per row-shard is:
with normalized statistics and .
The expert cost is:
where is the routed-token load on physical EP rank at layer .
Population Annealing Solver
The solver combines:
- Diverse fixed-row seeding: Window Shuffle, RandomizedBestFit, and EDPAwarePair operators generate structurally diverse feasible seeds
- Fixed-temperature population annealing: Parallel chains with Metropolis acceptance based on scalar energy
- Systematic resampling between temperature levels with Boltzmann weights
- Trajectory-best archive for non-regressing global incumbent
Empirical Validation / Results
Trainer-Measured Throughput
| Model | T/A params | Baseline | Reorder | RoutePack |
|---|---|---|---|---|
| Tiny | 7.9B/1.3B | |||
| Flash | 124B/5.1B |
- Tiny: Expert reordering improves throughput by 3.80%; packing adds 4.86% → total 8.85% over baseline
- Flash: Reordering improves 10.50%; packing adds 3.98% → total 14.89% over baseline
- All pairwise comparisons significant after Bonferroni correction (largest adjusted p-value: 0.0110)
Load-Balance Decomposition
Global EP-rank CV: LPT reduces mean global EP-rank coefficient of variation by more than 99% on both models.
Online load metrics from length-only FFD to guided packing:
| Model | EP peak sum | Tail peak | EP balance eff. | Attention | Joint |
|---|---|---|---|---|---|
| Tiny | -3.13% | -11.04% | 0.891 → 0.920 | +0.09% | -1.53% |
| Flash | -3.24% | -11.62% | 0.844 → 0.869 | +0.77% | -1.35% |
Key finding: Guided packing accepts a small increase in projected attention work (+0.09% to +0.77%) in exchange for larger reductions in EP peaks (3.13–3.24%) and the joint bottleneck (1.35–1.53%).
Theoretical and Practical Implications
Design Requirements Established
- Capacity efficiency must precede load-balance optimization — otherwise, lower peaks from extra microbatches increase total work
- Correct parallel scope matters: attention is per DP cell, expert work is per EDP shard (as induced by the deployed communicator)
- Complete-step optimization: independent EDP shards accumulate work at different rates; the primary tail objective must consider the slowest shard over the window
Framework Parallel Schedule
The modeled makespan from routing readiness is:
CPU packing introduces no additional admission straggler if:
Complexity Bounds
With saturated workers (), total host-side wall complexity is polynomial:
Conclusion
RoutePack demonstrates that routing replay can serve as both an expert-side and a data-placement signal in sparse RL systems. The key contributions are:
- Joint control: State-consistent, layer-wise expert rerouting coordinated with whole-sample data packing
- Joint objective: Linear-quadratic attention work combined with per-layer physical EP-rank tails within each projected EDP shard
- Practical implementation: Layer-wise LPT, state-consistent materialization, diverse seeding, and parallel population annealing with exact lexicographic scoring
Future directions identified by the authors:
- Scaling studies across datasets, larger EDP shards, multiple nodes, and nontrivial PP/CP degrees
- End-to-end instrumentation to quantify planning overhead in real deployments
- Communication-heavy deployments requiring calibrated topology-aware cost terms
- Kernel microbenchmark suites for shape-aware latency surfaces
- Extending evaluation to coding, STEM, instruction-following, and mixed-domain workloads
Related papers
- Harness Engineering: Anatomy, Architecture, and Evolution of Coding Agents — A Source-Code Study of Eleven Systems
Production harnesses replace agentic frameworks and RAG, relying on hand-rolled loops and deterministic retrieval, marking a platform turn in agent design.
- Spectral Allocation: Why Muon Outperforms Adam, and How to Improve Muon
Spectral probing reveals Transformer loss landscapes have a volatile head and tolerant bulk, motivating SAMuon which amplifies bulk step sizes to beat Muon by 13-24% in token efficiency.
- Belief-Calibrated Optimization: An Explicit World Model for Agentic Optimization
Belief-Calibrated Optimization, which persists an explicit falsifiable world model of environment responses, consistently outperforms vanilla agentic optimization across five benchmarks by up to +0.152 held-out passrate.