WorksComputer Science
RankCast: Phase-Aware Rank Balancing in MoE Serving
Abstract
Modern large language model (LLM) inference increasingly adopts disaggregated architectures that separate Prefill (P) and Decode (D) phases. Meanwhile, Expert Parallelism (EP) has been widely adopted in large Mixture-of-Experts (MoE) model serving. However, load imbalance still slows down MoE inference because each layer must wait for the busiest EP rank. The main source of latency differs between prefill and decode. Prefill is compute-bound, and its MoE layers' latency is determined by the maximum token count of the busiest rank. At the same time, under moderate batch sizes, Decode is memory-bound, so the latency is dominated by the maximum active-expert count across ranks. To solve both problems under a unified framework, we present RankCast, a system that reduces rank-level maximum token counts during prefill and active-expert counts during decode. For every token, RankCast preserves the predicted Top-p experts and chooses the remaining k-p from its Top-L candidates (L > k). In prefill, RankCast yields a price per rank that steers flexible assignments to less loaded ranks. In decode, RankCast closes experts on the busiest ranks while preserving the constraints for each token. Both paths are implemented and tested in the state-of-the-art inference frameworks SGLang and DeepEP. We overlap RankCast's kernels with model execution and reuse the existing DeepEP communication channel for metadata transmission. On Qwen3-235B-A22B with EP=8 and Qwen3.5-397B-A17B with EP=16, RankCast removes over 75% of the busiest rank's excess prefill load, improves prefill input throughput by up to 19%, and reduces decode time per output token by up to 10%. The quality cost is below one percentage point.
Introduction
Mixture-of-Experts (MoE) architectures are used in model families including Mixtral, LongCat, DeepSeek-V3/V4, Qwen3, and Kimi ([15, 24, 3, 5, 16] (Yang et al. 2025)). In MoE model serving, expert parallelism (EP) partitions expert weights across ranks and exchanges token activations through dispatch and combine collectives. These synchronization barriers cause the layer’s latency to be bottlenecked by the busiest rank.
Although a lot of models deploy per expert imbalance control algorithms including auxiliary loss and quantile balancing, during serving time, the frozen router still faces batch-level variation and domain drift, and what really matters here is the instantaneous load on each physical EP rank rather than the long-horizon utilization of each expert. DeepSeek-V3 notes that domain shift can cause this imbalance at inference and deploys redundant experts in serving to counter it ([3]). UltraEP reports pre-balancing inter-rank imbalance ratios of 1.30–4.01 in large-EP training and serving-prefill workloads and observes that expert popularity shifts across microbatches, layers, and data domains (Wei et al., 2026).
PD disaggregation is also widely adopted in modern MoE model serving. However, Prefill and decode have different balancing objectives. In prefill, computation and communication grow linearly with the number of tokens a rank receives, and the layer’s total latency is determined by the slowest rank due to synchronization barriers. In decode at moderate batch sizes, expert GEMM time is dominated by loading the weights of active experts, and additional tokens matter little until the tokens assigned to a single expert exceed one block’s capacity. Our profiling (Appendix § 13.§ 2) confirms both regimes. Reducing prefill latency therefore requires minimizing the maximum token load across ranks, whereas reducing decode latency requires minimizing the maximum number of active experts across ranks. OEA likewise observes that MoE decode latency scales approximately linearly with the number of active experts in this regime ((Oncescu et al., 2026)).
Current inference systems typically address this imbalance challenge through expert placement, replication, and predictive prefetching ([4, 10] (Yang et al. 2026; Zhu et al. 2026)). These approaches preserve the router’s expert choices but exchange memory or communication bandwidth for load balance.
UltraEP shows that placement built from historical load cannot track these fast shifts and can even worsen imbalance ((Wei et al., 2026)). Replicas occupy HBM that would otherwise hold KV cache; CRAFT reports that conventional replication reduces available KV-cache capacity by 19%–75% and can lower goodput when the concurrency loss exceeds the balancing gain ((Zhao et al., 2026)). Prefetching avoids permanent residency but must fit expert-weight transfers into a short hiding window and schedule them around token all-to-all ((Zhu et al., 2026)); across nodes, UltraEP deems moving expert state over the slower scale-out network impractical on the hot path ((Wei et al., 2026)). Both costs are acute in long-context serving, where KV-cache capacity is scarce and KV-cache transmission adds additional communication pressure.
Rerouting tokens to experts on less loaded ranks in Prefill or to already active experts in Decode provide a new way to avoid both costs. This is the key insight behind RankCast. However, changing a frozen model’s expert choices could affect output quality. RankCast (Figure 1) therefore limits rerouting through a protected Top- prefix and a Top- candidate set, with , so balancing changes only lower-ranked choices while keeping experts per token. For prefill, each rank receives a price that is subtracted from the scores of the candidates it hosts, so crowded ranks receive fewer token assignments.
Figure 1. RankCast overview. (a) Predicted next-layer routing defines protected Top- experts and Top- candidates. (b) Prefill uses rank prices to redistribute flexible assignments and reduce peak token load. (c) Decode closes low-cost experts to reduce the peak active-expert count while preserving protected experts and at least candidates per token.
Decode requires a different objective because token prices do not directly reduce the cost of loading expert weights. RankCast starts from the experts activated by the Top- routing and closes experts on the busiest ranks (Figure 1c), keeping every Top- expert open and leaving each token at least candidates from its Top- set. The target router then selects its Top- using its own scores with closed experts suppressed.
To make balancing decisions available before routing, both phases predict the next layer’s routing and carry compact metadata through DeepEP’s existing dispatch communication, so price and mask computations overlap with model execution (§ 4) and add no synchronization barrier.
Contributions.
We characterize and formulate EP balancing as a phase-aware, rank-level problem: prefill is bottlenecked by maximum per-rank token load, while decode is dominated by the maximum number of active experts across ranks.
We develop a prefill algorithm that preserves each token’s Top- prefix and balances the remaining assignments with compact distributed histograms and rank prices.
We develop a decode algorithm that closes experts to lower the peak active-expert count per rank while preserving each token’s protected experts and at least candidates.
We implement both paths in SGLang and DeepEP and evaluate them end-to-end. On Qwen3-235B-A22B with EP = 8 and Qwen3.5-397B-A17B with EP = 16, RankCast removes over 75% of the busiest rank’s excess prefill load, improves prefill input throughput by up to 19%, and reduces decode TPOT by up to 10%, at a quality cost below one percentage point.
Related Work
Training-time balancing. Switch Transformers, BASE, and Expert Choice balance expert utilization through auxiliary losses, balanced assignment, or expert-side selection (Fedus et al., 2022; Lewis et al., 2021; Zhou et al., 2022). Auxiliary-loss-free balancing instead updates per-expert routing biases from observed loads (Wang et al., 2024), which DeepSeek-V3/V4 combine with a small sequence-wise loss [3, 5]. Kimi K3’s Quantile Balancing derives each expert’s training-time bias from the dual of a balanced-assignment problem, which makes it a quantile of router-score margins that K3 estimates from all-reduced histograms [16]; RankCast’s prefill prices play the same dual role for physical ranks at serving time.
Placement, replication, and prefetching. Placement methods keep logical routing but change the expert-to-device mapping: DeepSeek-V3 and EPLB replicate and rearrange hot experts from estimated loads [3, 4], MoETuner solves a placement ILP over compute and communication skew [8], Semantic Parallelism co-schedules placement with rebatching [19], and Lina allocates more devices to experts predicted to be popular [18].
Replication and prefetching adapt capacity to hot experts: GRACE-MoE, CRAFT, and Libra allocate replicas by load skew over affinity-based groups, per-layer benefit, or lookahead (Han et al., 2025; Zhao et al., 2026; Yang et al., 2026); PROBE prefetches predicted hot experts within a hiding window (Zhu et al., 2026), and MoonEP prefetches redundant experts planned from the current router outputs [2]; UltraEP gathers exact post-gating loads per microbatch and jointly plans replication and rerouting (Wei et al., 2026). All of them trade replica storage or expert-state movement for balance.
Inference-time rerouting. Capacity-aware inference [11] limits the number of tokens assigned to each expert and drops or reroutes any tokens that exceed that expert’s capacity; LASER reroutes ambiguous tokens to less-loaded experts within a score-derived viable set (Shahout et al., 2025). Both target token-count balance, the prefill objective. RankCast also reroutes at inference time but balances physical-rank load and changes only lower-ranked choices within a limited candidate set.
Decode-time active-expert consolidation. In memory-bound decode, activating another expert can cost more than adding tokens to an active one. Lynx remaps low-affinity assignments onto a smaller active set [9]; SERE redirects secondary assignments to similar active experts (Wu et al., 2026); OEA lets additional assignments piggyback on experts the batch already activates (Oncescu et al., 2026). XShare is the closest comparison for the EP objective: it seeds a shared pool with each token’s top-ranked experts, grows it by batch-summed gating score up to a preset budget, and, in its EP-aware variant, applies the budget per GPU (Vankov et al., 2026). RankCast instead searches for closures that reduce the maximum active-expert count across ranks subject to each token’s predicted candidate-set and protected-prefix constraints. It validates closures jointly because closures on different ranks can affect the same token, and it overlaps the search with model execution through DeepEP (§ 4).
Phase-Aware RankCast Algorithms
In the previous sections, we discussed the different optimization objectives for Prefill and Decode. For Prefill, we reduce the maximum token load across ranks and for decode we reduce the maximum active experts of all ranks. In this section, we develop separate algorithms under the same routing constraint. For token with router scores , the candidate set and the protected set are
and every token’s final selection satisfies with . Both phases keep each token’s Top- experts and draw the rest from its Top- candidates.
RankCast computes rank prices in prefill and an expert mask in decode from predicted next-layer scores. The target layer uses its own scores to select the final experts (§ 4).
Rankcast for Prefill
Prefill balances rank load by adjusting each token’s flexible assignments. Consider tokens and experts distributed across EP ranks. Let be the rank hosting expert , and let be the set of experts on rank . Each token requires flexible assignments. We therefore retain only its top- flexible candidates on each rank, as any candidate outside this set cannot appear in the final selection.
For token and rank , denote their scores by . Missing slots are padded with and cannot be selected. Let be rank ’s target load for flexible assignments, with . The target is computed from the balance target after excluding the protected set (Appendix § 10.§ 2). We choose assignments to maximize their total score while giving each token exactly choices and matching each rank’s target. With indicating whether a candidate is selected, the problem can be defined as:
This transportation problem has an integral LP optimum whenever a feasible assignment exists (Appendix § 10.§ 1). We therefore solve it through its dual. Let be the threshold of token and be the price of rank . At the optimum, each token selects its top- candidates by the price-adjusted score . The threshold separates its -th and -th adjusted scores.
RankCast computes both variables in a single sweep, starting from zero prices. Each token first sets between its -th and -th largest flexible scores. Let denote the residual score, which measures how far a candidate lies above or below its token’s threshold. A candidate on rank is selected when its residual score exceeds . Each rank therefore sets between its -th and -th largest residual scores, so that it receives exactly its target load under the current thresholds. With denoting the -th largest score among token ’s flexible slots and the -th largest residual score on rank , the updates can be written as:
A rank requested by many tokens therefore receives a high price, which moves part of its load to other ranks.
The threshold update needs only the scores of token . The price update, however, needs the residual scores of all tokens on rank , which are spread across source ranks. RankCast therefore exchanges more compact histograms instead of individual scores. Let delimit shared bins, and let be the number of local residual scores on rank that fall in bin . Each source rank also reports its protected loads , for every rank to compute the same targets . The exchanged data size depends only on and (§ 4).
After summing the histograms, we scan the bins of rank from highest to lowest until the count reaches and interpolate within the last bin. This gives an estimate of with error at most one bin width (Appendix § 10.§ 3). Since a common shift of all prices does not change any token’s ranking, the final price is centered across ranks:
Boundary cases, where or all candidates on rank must be selected, set its price to the upper or lower end of the histogram range (Appendix § 10.§ 3).
At the target layer, the router keeps the protected experts and selects the remaining experts by their price-adjusted scores:
Rankcast for Decode
For decode, RankCast starts with the experts selected by Top- routing, and closes experts to reduce the active-expert count on the busiest ranks. A closed expert cannot be selected by any token. Each token is subject to the same constraints as in prefill. Let be the initial expert set and the protected set. The objective is
RankCast solves this problem greedily. Let be the slack of token , which counts the candidates it can still lose. An active, unprotected expert is closable if for every token with . Let the quality weight denote token ’s normalized routing-weight loss estimate for removing expert . Each rank orders its closable experts by increasing closure cost:
The cost is higher for candidates with larger weights and tokens with fewer alternatives.
Let be the number of active experts on rank and the count on the busiest rank, which Equation (6) minimizes. One rank cannot lower alone when another rank has the same count, so each round closes experts on several ranks together. Let be the headroom of rank below the busiest rank. To lower by , every rank must keep at most active experts, so rank closes its cheapest closable experts, or none if . Let be the -th cheapest closable expert on rank . Rank therefore closes once . We call the level of , and set for non-closable experts.
The maximum can be derived by considering two bounding conditions. First, rank has only closable experts, therefore . Second, experts closed together must not exhaust a token’s slack. Token can lose at most candidates, so must stay below , the -th smallest level among its candidates. The largest feasible reduction is therefore
When , a repair step tries other experts on the busiest ranks (Appendix § 11.§ 2). The solver repeats these steps until stops decreasing or the total reduction reaches an optional depth cap . The closed experts form the router mask of the target layer.
System Implementation
We implement RankCast in SGLang and integrate it with DeepEP’s normal prefill path and low-latency decode path. The implementation must meet three requirements: the balancing decision must be ready before the next router runs, it must add no collective or synchronization barrier to the per-layer critical path, and every rank must reach the same balancing decision.
Both phases therefore use the four-stage pipeline in Figure 2. They predict the next layer’s routing scores, exchange compact metadata, compute the balancing decision, and apply it at the next router. Prefill exchanges rank statistics to compute prices, and decode exchanges candidate lists to compute an active-expert mask. Both kinds of metadata ride on the token-count messages that DeepEP already exchanges. Every rank receives the same data and runs the same deterministic computation, so prices and masks need no separate broadcast.
Figure 2. Cross-layer execution of RankCast on one EP rank. Prediction and balancing overlap with model execution, using metadata carried by existing DeepEP communication to compute (a) prefill rank prices or (b) a decode expert mask for the next layer. Dashed dependencies indicate CUDA events; slack denotes the interval between solver completion and next-layer selection. LL: low-latency. Timelines are schematic.
Shared cross-layer router prediction. The balancing decision must be ready before the target layer routes its tokens, so RankCast predicts this routing at the current layer . As soon as the current hidden states are available, a side stream applies the next MoE layer’s gate weights,
and then the solvers run on these predicted scores while the main stream continues.
The prediction determines only the balancing decision. In prefill the decision is a per-rank price. The target layer takes the protected set and the candidate set from its own scores (Equation (5)), so a prediction error changes only the price and every token keeps its true Top- exactly. In decode the decision is an expert mask, fixed before the target layer runs, so an error can close a protected expert. Exact top-2 agreement between predicted and measured scores is 48–66%, but the true top-2 lies in the predicted Top- for 98.0–99.8% of tokens. A mis-ranked pair usually swaps experts of similar weight, so 87.9–97.8% of tokens keep both true top-2 experts after shedding (Table 5). Three safeguards bound a wrong prediction. A price in an edge bin of the histogram leaves that rank’s previous price in place, the solver keeps at least candidates open per token, and a row with fewer than valid candidates keeps all of that token’s experts open.
| 235B prefill | 235B decode | 397B decode | |
| True top-1 = predicted top-1 | 77.8% | 76–78% | 66% |
| True top-1 predicted top-2 | 91.4% | 92–93% | 84% |
| True top-2 set = predicted top-2 set | 63.1% | 66% | 48% |
| True top-2 predicted Top- | 99.7% | 99.8% | 98.0–98.6% |
| Tokens keeping their true top-1 expert | exact | 99.4–99.5% | 96.7–98.5% |
| Tokens keeping both true top-2 experts | exact | 97.6–97.8% | 87.9–94.5% |
Table 5. Accuracy of the protected prefix and the protection it achieves at , averaged over layers. The prefill column covers the 12 sampled MoE layers of Figure 3(b) in Appendix § 13.§ 1; the decode columns cover every layer after the first, on the chat and code captures of Table 7. Protection is measured after decode shedding. In prefill the selector uses the target layer’s own scores, so the true Top- is exact.
RankCast adds two online corrections (Appendix § 12.§ 2). The bias tracks the mean gap between predicted and measured router scores, and in prefill a per-rank offset raises the price of ranks that stay overloaded. Each is updated every few forwards with one all-reduce, outside CUDA graphs and off the per-layer critical path.
Histogram and price pipeline for prefill. Prefill runs the four stages of Figure 2(a) on a side stream. First, a statistics kernel evaluates Equation (9) for the local tokens and builds a statistic row, which includes the histograms of Section 3.1, the protected loads, and the token count, integers in total (about 8 KiB for and ). Second, DeepEP’s notify_dispatch, which already exchanges each rank’s token counts, carries this row to all ranks together with the counts, both within and across nodes. Third, once dispatch completes, a price kernel computes the prices of Equation (4) from the summed rows (Appendix § 12.§ 1). Finally, the next MoE layer’s selector applies Equation (5) with these prices, taking gating weights from the original logits.
Both kernels are small and overlap with model execution (Figure 2(a)). On Qwen3-235B, the statistics and price kernels take 54 and 44 per layer. The statistics kernel uses one warp per token and overlaps with the current layer’s expert selection and dispatch setup. The price kernel uses a single 128-thread block, and its slack spans the current layer’s expert computation and the next layer’s attention.
Expert-shedding pipeline for decode. Decode also runs the four stages of Figure 2(b) on a side stream. First, each rank evaluates Equation (9) for its local tokens and writes one candidate row per token, with the token’s Top- experts and their quality weights. Second, the rows ride the token-count messages of DeepEP’s low-latency dispatch to every rank, both within and across nodes (Appendix § 12.§ 3). Third, each rank runs the solver of Section 3.2 in a single CUDA block, which finishes during the current layer’s expert computation (Appendix § 12.§ 4). Finally, the target layer applies the mask by adding a large negative bias to the router score of every closed expert. Its Top- therefore runs unchanged and never selects a closed expert. The whole path is CUDA-graph compatible (Appendix § 12.§ 4).
Evaluation
Setup
Models and deployment. We evaluate RankCast on Qwen3-235B-A22B-Instruct-2507 ((Yang et al., 2025; Qwen Team, 2025)) in BF16 (94 MoE layers, 128 experts, ) and Qwen3.5-397B-A17B ((Qwen Team, 2026)) (60 layers, 512 experts, ). Both run on two nodes of H800 connected over RoCE, served by SGLang 0.5.12 ((Zheng et al., 2024)) with DeepEP 1.2.1 ((Zhao et al., 2025b)) and DeepGEMM ((Zhao et al., 2025a)). Qwen3-235B runs prefill and decode on separate nodes, each with TP = 8 and EP = 8. Qwen3.5-397B runs both phases in one instance across all 16 GPUs, with DP = 16 attention and EP = 16. Unless stated otherwise, RankCast uses candidates ( on Qwen3.5-397B) and protects each token’s top experts in both phases. Prefill uses histogram bins on Qwen3-235B and on Qwen3.5-397B, and decode uses quality weights without a depth cap. Appendix § 13.§ 3 reports ablations of , , and .
Workloads and baselines. Prefill experiments measure input throughput on prompts from ShareGPT ((ShareGPT, 2023)) and CodeContests ([20]), tiled or truncated to 4,096 tokens, and on 32,768-token windows of LongBench v2 ([1]). Decode experiments measure the median time per output token (TPOT) on WildChat ((Zhao et al., 2024)), ShareGPT, and CodeContests prompts at their natural lengths, and on ShareGPT prompts tiled to 1,024 tokens. Quality experiments run eight benchmarks on both models. We compare RankCast with online EPLB ([4]) in prefill, and with XShare ((Vankov et al., 2026)) and OEA ((Oncescu et al., 2026)) in an offline decode comparison. Throughput and quality changes are relative to native Top- routing on the same deployment, labeled Baseline in the tables. Appendix § 13.§ 1 lists all settings.
Throughput
Prefill. Table 1 reports the three workloads on both models. RankCast lowers the imbalance across EP ranks to 1.03–1.16 and removes 76–95% of the busiest rank’s excess load over the mean. On ShareGPT and CodeContests, input throughput rises by 16.4–19.4% on Qwen3-235B and 10.4–14.6% on Qwen3.5-397B. On LongBench v2, it rises by 4.2–7.3%, because the 32,768-token inputs make attention a larger share of each step. On ShareGPT and CodeContests, online EPLB ([4]) removes 73–91% of the excess and raises input throughput by 12.7–14.8% on Qwen3-235B and by 4.6–10.4% on Qwen3.5-397B. In these settings, RankCast gains 2.7–6.8 points more than EPLB. It also leaves a lower imbalance, except on ShareGPT at 16K tokens per rank on Qwen3.5-397B. Redundant experts lower the gain of EPLB on both models, because the extra expert copies use GPU memory and therefore reduce the number of concurrent requests. On LongBench v2, EPLB and EPLB-R remove only 6–43% of the excess and change throughput by −1.2 to +0.9%.
| Workload | Tokens per rank | EPLB | EPLB-R | RankCast | Baseline | EPLB | EPLB-R | RankCast |
| Qwen3-235B | ||||||||
| ShareGPT | 2K | +13.3% | +7.0% | +16.4% | 1.76 | 1.15 | 1.41 | 1.09 |
| 4K | +14.7% | +8.0% | +18.5% | 1.75 | 1.13 | 1.42 | 1.08 | |
| 8K | +13.8% | +6.6% | +19.4% | 1.75 | 1.11 | 1.46 | 1.08 | |
| CodeContests | 2K | +12.7% | +6.4% | +16.4% | 1.66 | 1.10 | 1.35 | 1.04 |
| 4K | +14.8% | +7.0% | +18.8% | 1.66 | 1.09 | 1.36 | 1.04 | |
| 8K | +14.2% | +7.5% | +19.3% | 1.66 | 1.06 | 1.39 | 1.04 | |
| LongBench | 2K | −0.4% | −1.2% | +7.3% | 1.66 | 1.60 | 1.61 | 1.16 |
| 4K | +0.1% | −0.2% | +7.1% | 1.65 | 1.58 | 1.61 | 1.15 | |
| 8K | +0.9% | +0.3% | +4.3% | 1.47 | 1.39 | 1.44 | 1.10 | |
| Qwen3.5-397B | ||||||||
| ShareGPT | 4K | +4.6% | +4.4% | +10.8% | 1.51 | 1.14 | 1.20 | 1.09 |
| 8K | +7.4% | +7.1% | +11.2% | 1.50 | 1.11 | 1.17 | 1.07 | |
| 16K | +7.7% | +7.3% | +10.4% | 1.50 | 1.09 | 1.13 | 1.11 | |
| CodeContests | 4K | +7.1% | +6.5% | +13.9% | 1.55 | 1.08 | 1.19 | 1.04 |
| 8K | +9.9% | +9.1% | +14.6% | 1.55 | 1.06 | 1.17 | 1.03 | |
| 16K | +10.4% | +9.7% | +14.0% | 1.54 | 1.05 | 1.15 | 1.03 | |
| LongBench | 8K | −0.2% | +0.2% | +4.2% | 1.26 | 1.15 | 1.16 | 1.05 |
| 16K | +0.7% | — | +4.4% | 1.25 | 1.14 | — | 1.05 |
Table 1. Prefill results at three chunked-prefill sizes per model. Throughput gain is relative to SGLang’s native Top- routing (Baseline). Imbalance is the max-to-mean token count across EP ranks. Bold marks the best value of each metric in each row. Online EPLB rebalances every 50 forward passes on ShareGPT and CodeContests; EPLB-R adds 8 redundant experts on Qwen3-235B and 16 on Qwen3.5-397B.
To reach larger we replay the prices offline on captured scores. On Qwen3-235B prefill chunks, native imbalance grows from 1.60 at to 5.30 at as each rank holds fewer experts, and RankCast removes 53–70% of the excess. On Qwen3.5-397B it removes 72% of the excess at and 51% at , where native imbalance reaches 9.34 (Table 11 in Appendix § 13.§ 3).
Table 11. Offline replay of the prefill prices at larger EP degrees. Imbalance is max-to-mean, native RankCast, with the share of the excess over the mean removed in parentheses. Qwen3-235B uses 16,384-token prefill chunks; Qwen3.5-397B uses decode-shaped captures combined into 16,384-token batches.
| Qwen3-235B, prefill chunk | Qwen3.5-397B, code | |
| 8 | 1.60 1.19 (68%) | — |
| 16 | 2.30 1.36 (70%) | 2.48 1.39 (72%) |
| 32 | 3.45 1.86 (64%) | 3.62 1.87 (66%) |
| 64 | 5.30 2.97 (53%) | 5.53 2.92 (57%) |
| 128 | — | 9.34 5.30 (51%) |
Per-batch prices. The slow per-rank offset of Appendix § 12.§ 2 works like a training-time load bias. It accumulates across forward passes and does not react within one. Table 2 runs it alone. On ShareGPT at 4K, consecutive batches route similarly, so one standing offset fits them all and recovers most of the gain, lowering imbalance from 1.75 to 1.20. On 32,768-token LongBench v2 inputs it moves imbalance only from 1.66 to 1.65 and costs 0.8% of throughput. A standing offset cannot follow imbalance that changes from batch to batch, while per-batch prices reach 1.16 and +7.4%.
| Workload | Arm | Throughput gain | Imbalance |
| ShareGPT, 4K | Top- | — | 1.75 |
| alone | +14.7% | 1.20 | |
| + per-batch prices | +18.1% | 1.08 | |
| LongBench v2, 32K | Top- | — | 1.66 |
| alone | −0.8% | 1.65 | |
| + per-batch prices | +7.4% | 1.16 |
Table 2. The slow offset alone against full RankCast on Qwen3-235B prefill, one run per arm, with the clamp on relaxed to the full price range. Imbalance is the max-to-mean token count within one forward pass.
Decode. Table 3 reports median decode TPOT on four workloads. Decode shedding raises by 6.1–8.2% on Qwen3-235B and by 8.8–11.1% on Qwen3.5-397B. Natural-length prompts still gain 6.1–11.1%, so the gain does not depend on tiled inputs. On Qwen3-235B, decode shedding lowers the mean number of active experts on the busiest rank from 14.4 to 9.7 (Figure 3(a) in Appendix § 13.§ 1). Across 11 configurations, median TPOT is linear in this count, with a slope of 0.52 ms per expert (). The intercept of 20.1 ms is the part of TPOT that shedding cannot reduce.
| Workload | Prompt | Baseline | RankCast | Baseline | RankCast | ||
| WildChat | 29 | 27.68 | 26.10 | +6.1% | 41.74 | 37.67 | +10.8% |
| ShareGPT | 91 | 27.69 | 26.11 | +6.1% | 40.76 | 37.48 | +8.8% |
| ShareGPT, tiled | 1,024 | 27.59 | 25.58 | +7.9% | 37.53 | 34.16 | +9.9% |
| CodeContests | 3.5K | 27.41 | 25.33 | +8.2% | 52.19 | 46.97 | +11.1% |
Table 3. Median decode TPOT (ms) with 1,024 output tokens per request. Qwen3-235B keeps up to 96 requests in flight, and Qwen3.5-397B up to 128. Prompt gives the median prompt length in tokens. is the relative gain in .
Figure 3. (a) Median decode TPOT against the mean number of active experts on the busiest rank for 11 configurations of Qwen3-235B at ISL 1024 and global batch 96. The dashed line is a least-squares fit. (b) Cross-layer prediction accuracy on 12 sampled MoE layers of Qwen3-235B during prefill. The curves give the share of each token’s true Top-8 experts inside the predicted Top-8 and inside the predicted Top-16, and the share of their routing weight inside the predicted Top-16.
Decode baselines. XShare and OEA select experts from the true router scores of the whole batch. Neither has an open-source implementation for expert parallelism. Running them on our cross-layer prediction would therefore require changing their algorithms. We instead compare the three methods offline on router scores captured from Qwen3-235B decode (Table 7 in Appendix § 13.§ 1). XShare and OEA receive the true scores, whereas RankCast uses its prediction and adds no collective. At the same , XShare and OEA still displace 1.9–6.0 times as much routing probability as RankCast.
| Workload | RankCast | XShare | OEA | |
| ShareGPT | 14.56 | 0.065% | 2.38× | 1.94× |
| 13.59 | 0.180% | 6.02× | 4.75× | |
| 12.01 | 0.600% | 3.60× | 3.83× | |
| 11.59 | 0.811% | 2.83× | 2.84× | |
| LiveCodeBench | 12.96 | 0.062% | 4.21× | 1.92× |
| 12.05 | 0.133% | 1.96× | 2.25× | |
| 10.25 | 0.428% | 3.00× | 4.15× | |
| 9.22 | 0.731% | 2.34× | 2.43× |
Table 7. Offline comparison of decode shedding with XShare (Vankov et al., 2026) and OEA (Oncescu et al., 2026) on decode batches of Qwen3-235B. is the mean active-expert count on the busiest rank. Each row compares the methods at the same . Every method keeps the true top-1 expert of at least 99% of tokens and gives every token experts. The RankCast column gives the routing probability displaced from each token’s Top-. The XShare and OEA columns give their displaced probability as a multiple of RankCast’s.
Overhead. Prefill balancing adds about 0.5% to the prefill step time on both models. Decode shedding adds 0.7% to the decode step time on Qwen3-235B and 0.9% on Qwen3.5-397B, mostly through the prediction and masking kernels. Its solver takes 9–17 per layer on Qwen3-235B and 58 on Qwen3.5-397B. The solver runs on a side stream during the layer’s expert computation, so almost none of this time is exposed.
Quality
Table 4 reports the accuracy change of prefill balancing, decode shedding, and both together. On Qwen3-235B, prefill balancing lowers each of the four ten-repeat benchmarks by 0.3–0.7 pp. Decode shedding changes no benchmark by more than 0.65 pp. With both enabled, the largest drop is 0.84 pp, on LiveCodeBench. On Qwen3.5-397B no benchmark drops by more than 0.43 pp. Appendix § 13.§ 1 compares these changes with the spread between baseline repeats.
| Benchmark | Baseline | Prefill | Decode | Both | Baseline | Prefill | Decode |
| MMLU-Redux 2.0 | 0.9105 | −0.02 | −0.13 | −0.17 | 0.9254 | +0.18 | −0.01 |
| MATH-500 | 0.9813 | −0.07 | −0.20 | +0.00 | 0.9160 | −0.07 | −0.30 |
| MMMLU | 0.8198 | −0.16 | −0.22 | −0.11 | 0.8673 | −0.04 | −0.25 |
| RULER | 0.8787 | −0.40 | −0.31 | −0.73 | 0.9419 | −0.20 | +0.02 |
| GPQA-Diamond | 0.7621 | −0.67 | −0.10 | −0.46 | 0.8576 | +0.03 | −0.39 |
| AIME 2025 | 0.6963 | −0.32 | −0.02 | −0.30 | 0.8707 | +0.32 | −0.09 |
| IFEval strict | 0.8848 | −0.31 | −0.65 | −0.59 | 0.8854 | +0.02 | −0.19 |
| LiveCodeBench v5 | 0.7008 | −0.43 | −0.59 | −0.84 | 0.8467 | −0.43 | −0.34 |
Table 4. Quality change in percentage points, relative to native Top- routing. Prefill enables prefill balancing, Decode enables decode shedding, and Both enables the two together. Baseline gives the accuracy of native routing. Appendix § 13.§ 1 lists the repeat counts.
Prediction Accuracy
In Table 5, the predicted top-2 set matches the true one for 63.1% of tokens in 235B prefill, 66% in 235B decode, and 48% in 397B decode. After shedding, 97.6–97.8% of 235B tokens and 87.9–94.5% of 397B tokens keep both true top-2 experts. The true top-2 lies inside the predicted Top- for 98.0–99.8% of tokens, so a mis-ranked expert is still a candidate. Mis-ranked pairs usually swap experts of near-equal weight. Prefill retention is exact by construction. Qwen3.5-397B has a flatter router, so exact ranking is harder.
Conclusion and Limitations
We presented RankCast, a unified framework for rank-level load balancing in expert-parallel MoE inference. Prefill and decode share the same routing constraint, which retains each token’s predicted Top- experts. They differ only in the objective, which is the maximum per-rank token load in prefill and the maximum active-expert count in decode. On Qwen3-235B-A22B and Qwen3.5-397B-A17B, RankCast improves prefill input throughput by up to 19% and reduces decode TPOT by up to 10%, at a quality cost below one percentage point.
RankCast changes which experts a token uses, so unlike expert placement or replication it is not lossless. A deployment that needs the trained routing exactly should use placement instead. RankCast acts on routing and placement acts on weights, so the two can be combined. We have not measured them together.
We evaluate two models from one family. In both, the next layer’s routing can be predicted from that layer’s own gate weights. Routers with group-limited or sigmoid gating remain untested. Our experiments use at most 16 GPUs at EP = 16. The kernels and the serving integration are not fully optimized, so the overhead in § 5.2 is an upper bound.
AI Use Statement
We used generative AI tools to implement code: parts of the RankCast solver and its serving integration were AI-assisted. We additionally used them to edit the paper for readability and to write auxiliary scripts. We did not use them for the conceptual framework, hypotheses, experiment design, or interpretation of results; synthetic data, dataset cleaning, qualitative analysis, and translation are not applicable. The authors tested all AI-assisted code against the reference implementation of Appendix C, and take responsibility for the final content of this work.
Ethics Statement
This work improves the serving efficiency of existing, publicly released Mixture-of-Experts models and introduces no new model, training procedure, or dataset. All experiments use public model weights and benchmark datasets, involve no human subjects, and collect no personal data. Because
RankCast changes routing at inference time, we report the measured quality change of every configuration, including degradations, so that deployers can weigh throughput against accuracy.
Reproducibility Statement
§ 5 and Appendix § 13.§ 1 specify the model, serving stack, hardware, workloads, seeds, warmup and measurement windows, and repetition counts behind every reported number, and Appendix § 13.§ 3 reports the ablations of the protected prefix , the depth cap , the quality weights, and the candidate width . The prefill solver is specified by Equations (2)–(5), with its dual derivation, capacity construction, and histogram error bound in Appendix § 10; the decode solver by Equations (6)–(8), with its quality weights, closure order, repair step, and depth cap in Appendix § 11. Appendix § 12 documents the kernels, the metadata exchange, the online corrections, the candidate-row layout, and the reference implementation against which the GPU solver was validated.
Prefill Solver Details
Dual Derivation of the Rank Prices
Exact LP relaxation. Let slot be valid if , and let denote the number of valid slots on rank . Dropping the padded slots and relaxing to gives
This is a transportation problem. Token supplies units, rank demands units, and each valid slot is an edge of capacity one. Its constraint matrix, including the bounds , is totally unimodular, and and are integers. Every vertex of the feasible polytope is therefore integral. Whenever a feasible assignment exists, the relaxation has an integral optimum with the same value as Equation (2).
Dual and block updates. Let the threshold and the price be the multipliers of the token and rank constraints, and let . The dual function is
By complementary slackness, an optimal assignment selects every slot whose adjusted score exceeds and no slot whose adjusted score falls below it. Each token therefore takes its top- adjusted scores, as in Equation (5).
For fixed , let denote the -th largest adjusted score of token . Any threshold in
minimizes over . For fixed , let denote the -th largest residual score on rank , across all source ranks. Any price in
minimizes over . Starting from and taking the midpoints of both intervals gives Equation (3). If or , the price interval becomes one-sided:
One sweep and centering. One sweep does not in general reach the dual optimum, so rank need not receive exactly flexible assignments. Each further sweep would need another histogram exchange, so RankCast runs one sweep. Because , raising every and lowering every by the same amount leaves unchanged. Equation (4) fixes this shift by subtracting the mean price.
Flexible Target Loads
Let denote the balanced total load of rank . The assignments are split as evenly as possible across ranks:
Every rank obtains from the token counts of the statistic rows, so all ranks compute the same . Let denote the protected load of rank , summed over all source ranks. Every token has protected experts, so the targets sum to . A target can be negative or exceed , and clipping it to alone can change the sum. RankCast therefore subtracts a shared offset before clipping:
Every token has at least valid slots, so . The clipped sum falls continuously from to as grows, so bisection finds . The resulting is the point closest to that satisfies the bounds and the sum. RankCast rounds each down and gives the remaining units, one each, to the unsaturated ranks with the largest fractional parts. The integer targets therefore satisfy and . These bounds do not guarantee a feasible assignment, because several ranks can compete for the slots of the same tokens. The prices remain defined in that case.
Accuracy of the Histogram Estimate
The histograms use equal-width bins on with , so each bin has width . Scores outside this range are counted in the first or the last bin. For rank , the price kernel accumulates bin counts from the top until the count reaches . Let denote the bin where it stops, and let denote the count above this bin. The estimate interpolates linearly inside bin :
Integer counts sum exactly, so bin contains the exact order statistic whenever is not an edge bin. Both values then lie in the same bin:
The upper endpoint of Equation (13) is an exact block minimizer, like the midpoint of Equation (3). Each price is therefore within of an exact update. Centering shifts every price equally and does not change routing. A token keeps its exact selection whenever the gap between its -th and -th price-adjusted scores exceeds . If , the kernel sets the price just above . If , it sets the price just below . These values realize Equation (14) within the histogram range.
Decode Solver Details
Quality Weights and Closure Order
Quality weights. Let denote the predicted score of expert for token , and let denote the -th largest predicted score of token . Let , and define likewise. Closing an expert of the predicted Top- approximately hands its routing weight to the -th expert. The quality weight is this loss, normalized by the loss for the top expert and rounded up to a multiple of :
and for the other candidates. Each weight therefore takes one of four values and fits in two bits. Without quality weights, the solver sets every to one.
Closure order. Ties in the closure cost are broken by the number of tokens that list the expert as a candidate, fewest first, because closing such an expert reduces the slack of fewer tokens. Remaining ties are broken by expert identifier, so every rank computes the same order.
Closure set. Let denote the experts that § 3.2 closes to lower by . For , closing lowers by exactly and keeps every token’s coverage. is the largest reduction when every rank closes only its cheapest closable experts. Closing other experts may allow a larger reduction, so the solver does not guarantee an optimum of Equation (6). The solver works on predicted scores, so these guarantees hold for the predicted sets and .
Repair Step
in two cases. Either a busiest rank has no closable expert, or some token would lose more than its slack if every busiest rank closed its cheapest closable expert. In the first case, no closure can lower . In the second case, closing other experts on the busiest ranks may still lower by one. The repair step searches for one such expert per busiest rank:
Each busiest rank starts with index .
Let denote the proposal. A token conflicts with if .
If no token conflicts with , the solver closes , and decreases by one.
Otherwise, every busiest rank whose proposed expert is a candidate of a conflicting token sets , and the search returns to step 2. The repair fails after eight attempts or when some exceeds .
These ranks advance together, so each attempt is one parallel step. The joint advance can skip a feasible proposal that advancing one rank at a time would find.
Solver Loop and Depth Cap
The depth cap bounds the total reduction of within one MoE layer of one decode step. The default imposes no cap. Let denote the reduction reached so far, starting from . In each round with , the solver closes with
and sets . A round with runs the repair step instead, and a successful repair sets . After each round, the solver recomputes the slack, the active counts, , and the closure costs. It stops when or when the repair fails. Every round except the last lowers by at least one, so the loop ends after at most rounds, where is the initial value of . Once stops decreasing, the solver closes no further experts, because such closures would move routing weight without lowering .
Implementation Details
Both phases predict the routing of the next MoE layer from the hidden states of the current one. The first MoE layer has no predecessor, so its prefill price is the load-feedback offset alone and its decode routing stays native Top-. The last MoE layer computes no prediction. Only the two online corrections carry state across forwards.
Prefill Pipeline
The statistics kernel runs on the histogram stream of Figure 2(a) and reads a copy of . The main stream waits for it just before notify_dispatch reads the statistic row. notify_dispatch already copies each rank’s token-count row to every other rank, and RankCast appends its statistic row to this copy. A row holds int32 values, or 8,240 bytes for and after padding to 16 bytes. Across nodes, notify_dispatch sends the row over the RDMA queue pair of the counts, forwards it to the local ranks over NVLink, and sums the rows before it returns. A rank without tokens sends an all-zero row, because every rank must join the exchange.
Once dispatch completes, the price kernel computes the target loads and raw prices of Appendices § 10.§ 2 and § 10.§ 3 from the summed rows. It then subtracts the mean price and adds the load-feedback offset of Appendix § 12.§ 2. Integer sums and a fixed order of floating-point operations make the prices bit-identical on every rank. At the target layer, a fused Triton kernel replaces the native Top- and applies Equation (5) with these prices.
Online Corrections
Score bias. The bias of Equation (9) tracks the mean gap between the target layer’s router score of expert and its prediction without the bias. Every 32 forwards, an all-reduce sums the gaps across ranks, and each rank updates
Load feedback. In prefill, a per-rank offset raises the price of ranks that stay overloaded. Every forwards, an all-reduce gives the number of expert assignments that each rank received in recent forwards. Let denote the log load share of rank , which is zero under an even split, and let denote its mean over ranks. The offset moves toward balance:
Each step is limited to , each offset to , and the offsets are kept centered. The price kernel adds to the centered price . Both corrections update outside CUDA graphs at the end of a forward.
Decode Candidate Rows
Let denote the maximum number of decode tokens per rank. A row lists a token’s Top- predicted experts in descending order, together with the 2-bit code $3\omega_{i,e}p entries form , and the first form the initial selection. The rows travel in the token-count messages of DeepEP’s low-latency dispatch as two byte arrays:
For Qwen3-235B (, , ), they take 5 KiB per MoE layer. Each rank writes its rows into its own slice of a zeroed buffer, and each receiver sums the buffers of all ranks. The slices are disjoint, so the sum recovers every rank’s rows. Across nodes, a rank writes its rows over the RDMA queue pair of its token count before it sends the count. The queue pair delivers in order, so the rows arrive before the count and need no separate signal.
Decode Solver Kernel
Each rank runs the solver as one CUDA block. The block keeps the candidate graph in shared memory as bit matrices:
Two more matrices, and , mark the tokens whose code for expert has its high or low bit set. Let denote the tokens with slack , and let count set bits. The closure cost of (7) then needs only population counts:
Scaling every cost by makes it an integer, so every rank orders the experts identically. For each level, the solver keeps a mask of the experts at that level. Each token counts its candidates level by level to find , and a block-wide minimum gives . After the last round, the solver writes a router bias of for every closed expert and 0 otherwise. The kernel supports up to 16 ranks, 512 candidate rows, and 32 experts per rank.
CUDA graphs and validation. The solver uses only preallocated buffers on the caller’s stream and never synchronizes with the host, so the decode path can be captured in a CUDA graph. It never stops on invalid input, because a stopped rank would stall the dispatch of every other rank. A row with fewer than valid candidates instead gets zero slack, which keeps that token’s experts open. A scalar NumPy reference reproduces the CUDA masks bit for bit on captured Qwen3-235B router scores and on synthetic cases.
Evaluation Details
Settings and Protocols
System settings. On Qwen3-235B, SGLang’s mini-lb routes requests to the prefill and decode workers, and Mooncake (Qin et al., 2025) transfers the KV cache between them. Prefill uses DeepEP normal mode without CUDA graphs, and decode uses DeepEP low-latency mode with CUDA graphs. No run uses the radix cache. Online EPLB rebalances every 50 forward passes, and the other configurations keep a static expert placement. RankCast changes only which experts a token uses, and all of its communication stays inside the EP group. It neither adds traffic to the KV path nor synchronizes with it.
Throughput runs. Each run discards its warmup requests and then measures 300 seconds, or 180–240 seconds for the natural-length decode workloads. Prefill baseline and RankCast runs alternate, with two or three runs per configuration. The LongBench v2 and EPLB results are single runs. Each decode configuration runs in one server launch. On Qwen3-235B, each natural-length decode cell averages two runs, and the second run uses a new seed and the reverse order. All other decode cells are single runs.
Prefill. LongBench v2 inputs come from all six domains, with at most four 32,768-token windows per document. Each request generates one output token, and the client keeps a fixed number of requests in flight. On Qwen3-235B, this number is 64 for the 4,096-token workloads and 24 for LongBench v2, which runs with TP attention. On Qwen3.5-397B, it is 128, 192, and 320 at the three chunk sizes, and 32 for LongBench v2. The max-to-mean token ratio is averaged over all MoE layers and over the forward passes that carry at least 90% of the tokens of the largest one. The small-chunk ShareGPT baseline on Qwen3-235B comes from other sessions, whose baseline throughput varies by 0.4%. Table 6 gives the absolute input throughput.
| Workload | Tokens per rank | Baseline | EPLB | EPLB-R | RankCast |
| Qwen3-235B | |||||
| ShareGPT | 2K | 44.6 | 50.3 | 47.5 | 51.9 |
| 4K | 48.7 | 55.9 | 52.6 | 57.7 | |
| 8K | 50.0 | 57.0 | 53.4 | 59.7 | |
| CodeContests | 2K | 45.4 | 51.2 | 48.3 | 52.8 |
| 4K | 50.1 | 57.5 | 53.6 | 59.5 | |
| 8K | 51.5 | 58.8 | 55.3 | 61.4 | |
| LongBench | 2K | 30.3 | 30.2 | 30.0 | 32.5 |
| 4K | 31.8 | 31.8 | 31.7 | 34.0 | |
| 8K | 33.1 | 33.4 | 33.2 | 34.5 | |
| Qwen3.5-397B | |||||
| ShareGPT | 4K | 120.1 | 125.8 | 125.5 | 133.1 |
| 8K | 123.2 | 132.7 | 132.4 | 136.9 | |
| 16K | 122.6 | 136.1† | 135.6† | 135.4 | |
| CodeContests | 4K | 120.5 | 129.1 | 128.3 | 137.2 |
| 8K | 124.6 | 137.0 | 136.0 | 142.8 | |
| 16K | 125.1 | 140.8† | 139.9† | 142.6 | |
| LongBench | 8K | 122.3 | 122.0 | 122.5 | 127.4 |
| 16K | 121.4 | 122.3 | — | 126.7 |
Table 6. Prefill input throughput (thousand tokens/s) behind the gains of Table 1. †Run with a larger state cache for the linear-attention layers; the gain in Table 1 is relative to a baseline with the same cache.
Decode. Each request generates 1,024 output tokens, with end-of-sequence tokens ignored. In the tiled ShareGPT workload, requests arrive at a fixed rate, and the global batch size caps the number in flight. The natural-length workloads keep the global batch size of requests in flight, which is 96 on Qwen3-235B and 128 on Qwen3.5-397B. We report median TPOT, because output throughput does not follow decode speed in these runs. The tiled workload nearly keeps up with its arrival rate, and on short natural-length prompts the bottleneck lies outside decode. On Qwen3.5-397B, TPOT counts only pure decode steps, which excludes the interleaved prefill chunks. The active-expert count on the busiest rank is averaged over layers and steady-state decode steps. Its run-to-run spread is about 0.2 experts, measured on the prefill-balancing runs, which do not change decode routing. Figure 3(a) and Table 9 come from an earlier set of runs on the tiled workload. In those runs, decode shedding without a depth cap gained 9.1%.
Table 9. Decode shedding on Qwen3-235B for each depth cap with quality weights, and for without them, at ISL 1,024 and global batch 96. is the mean number of active experts on the busiest rank. This count and the gain in 1/TPOT come from the throughput runs. Quality changes are in percentage points. LiveCodeBench and IFEval use ten repeats, or 13 for with quality weights. MMLU-Redux uses three.
| Weights | 1/TPOT | LiveCodeBench v5 | IFEval strict | MMLU-Redux 2.0 | ||
| 1 | on | 13.68 | +0.6% | −1.00 | −0.35 | −0.23 |
| 2 | on | 12.61 | +3.0% | −0.31 | +0.04 | −0.20 |
| 4 | on | 10.76 | +7.7% | −0.45 | −0.11 | −0.21 |
| 8 | on | 10.03 | +9.1% | −1.27 | −0.13 | −0.10 |
| on | 9.74 | +9.1% | −0.59 | −0.65 | −0.13 | |
| 4 | off | 10.75 | +7.7% | −1.49 | −0.50 | −0.26 |
Offline decode comparison. Table 7 replays router scores captured from Qwen3-235B decode. Each workload uses two disjoint batches of 96 sequences, with 64 decode steps over all 94 MoE layers. The ShareGPT capture uses 1,024-token contexts, and the LiveCodeBench capture uses 2,048-token contexts. Native routing gives on ShareGPT and on LiveCodeBench. Every method closes experts with the additive bias of § 4. The native Top- then runs on the biased true scores. RankCast uses , , and its cross-layer prediction, and its rows come from different depth caps . RankCast protects the predicted top experts, so it keeps the true top-1 expert of 99.2–99.9% of tokens. XShare follows Algorithm 6 of its paper, and OEA follows its published algorithm. Both receive the true router scores of the batch. A baseline matches a RankCast row when its is at most 0.15 above RankCast’s.
Quality. The quality suite comprises MMLU-Redux 2.0 [7], MATH-500 [12, 21], MMMLU (OpenAI, 2024), RULER [13], GPQA-Diamond (Rein et al., 2024), AIME 2025 [23], IFEval strict (Zhou et al., 2023), and LiveCodeBench v5 [14, 22]. MMMLU uses a fixed 10% stratified subset of each of its 14 languages. RULER uses 100 instances of each of its 13 tasks at 4K, 16K, and 32K tokens. Quality runs use 2K tokens per rank on Qwen3-235B and 1K on Qwen3.5-397B, with server seed 20260809. Generation is non-thinking and samples with temperature 0.7 and nucleus probability 0.8 from the 20 most likely tokens. RULER uses greedy decoding. Each repeat starts a new server session. On Qwen3-235B, MMLU-Redux 2.0, MATH-500, MMMLU, and RULER use three repeats, and the other four benchmarks use ten. Decode shedding uses 13 repeats on GPQA-Diamond and AIME 2025. On Qwen3.5-397B, prefill balancing uses the same counts, except five repeats on AIME 2025. Decode shedding uses two repeats on the first four benchmarks, ten on AIME 2025, and five on the other three. Qwen3.5-397B runs both phases in one instance, so it enables only one of the two at a time. The change of repeat is the score of repeat minus the baseline score of repeat . Its standard deviation is 0.5–1.3 pp on the four ten-repeat benchmarks, which are also the four smallest. On MMLU-Redux 2.0, MMMLU and MATH-500 it is at most 0.23 pp.
Measurement resolution. On MMLU-Redux 2.0 and MMMLU the 95% confidence interval of every change stays within ±0.5 pp, so three repeats resolve changes of this size. The four ten-repeat benchmarks vary more. Table 8 therefore reports a baseline spread for each of them, the largest gap the benchmark shows when nothing has changed. We split the ten baseline repeats into two halves, take the difference between the halves, and report its 95th percentile over all splits. The largest drop anywhere is 0.85 pp, and on each small benchmark the largest drop is at or below the spread. A paired test over per-question scores finds 3 of the 38 comparisons significant at the 0.05 level.
| Benchmark | Questions | Qwen3-235B Largest drop | Qwen3-235B Baseline spread | Qwen3.5-397B Largest drop | Qwen3.5-397B Baseline spread |
| GPQA-Diamond | 198 | 0.85 | 1.35 | 0.47 | 1.20 |
| AIME 2025 | 30 | 0.54 | 0.89 | 0.09 | 1.57 |
| IFEval strict | 541 | 0.65 | 0.65 | 0.00 | 0.67 |
| LiveCodeBench v5 | 880 | 0.84 | 0.89 | 0.43 | 0.66 |
| MMLU-Redux 2.0 | 5,700 | 0.21 | — | 0.01 | — |
| MATH-500 | 500 | 0.40 | — | 0.30 | — |
| MMMLU | 19,600 | 0.22 | — | 0.25 | — |
| RULER | 3,900 | 0.73 | — | 0.20 | — |
Table 8. Largest quality drop of each benchmark over all settings of Table 4, against the baseline spread, the 95th percentile of the difference between two halves of the ten baseline repeats over all splits. The four benchmarks with three repeats have no such split. Percentage points.
Prediction accuracy protocol. Figure 3(b) uses Qwen3-235B prefill with 2K tokens per rank. It samples the 12 target layers 4, 12, …, 92 over two forward passes on all eight ranks, 393,216 token–layer pairs in total. For token , let denote its predicted scores and its router scores at the target layer. The Top- recall is
and the weight recall is the share of the routing weight of that falls on experts inside .
GEMM Profiling
We profile the grouped expert GEMM of DeepGEMM, which computes both expert projections of one MoE layer on one rank. Figure 4(a–Figure 4c) measures it offline on one GPU with the expert shapes and experts per rank of both models. Decode and prefill lay out the tokens differently, so we measure each layout.
Figure 4. GEMM profiling. (a–c) Offline latency of the grouped expert GEMM for one MoE layer on one GPU, with the expert shapes and experts per rank of Qwen3-235B at EP = 8 and Qwen3.5-397B at EP = 16. (a) Decode layout with every expert on the rank active. (b) Decode layout with 8 tokens per active expert. (c) Prefill layout with every expert on the rank active. The shaded bands mark the tokens per expert at the batch sizes of Table 3 and at the chunk sizes of Table 1. (d) Expert GEMM time of each MoE layer and EP rank during Qwen3-235B prefill at 8K tokens per rank, against the token load of the rank divided by the layer mean. The dashed lines are least-squares fits.
Figure 4(a) varies the tokens per expert in the decode layout while every expert on the rank is active. Latency changes by less than 1.3% from 1 to 64 tokens per expert, because one 64-token tile holds all tokens of an expert and the time goes to reading its weights. The decode batches of Table 3 place 2.5–6 tokens on an average expert. Decode GEMM time is therefore set by the number of active experts. Figure 4(b) shows that each active expert adds 9.5 s on Qwen3-235B and 6.2 s on Qwen3.5-397B. Their ratio of about 1.5 matches the ratio of their expert intermediate sizes, 1,536 and 1,024.
Figure 4(c) repeats the token sweep in the prefill layout. Beyond 512 tokens per expert, latency grows linearly with the token count (). The prefill chunks of Table 1 place 1,024–5,120 tokens on an average expert. Prefill GEMM time is therefore set by the token load of the rank. Figure 4(d) confirms this in serving on Qwen3-235B. The GEMM time of each layer and rank grows linearly with the token load of the rank (). At the mean load, the part that does not depend on the load is 2.2% of the GEMM time.
Ablations
Protected prefix . The protected prefix costs no prefill throughput. We vary on Qwen3-235B with ShareGPT 4K inputs at 2K tokens per rank. Input throughput differs by at most 0.3% across , 1, and 2. Imbalance differs by less than 0.01. Decode is more sensitive, because the mask is applied before the target layer runs. The largest benchmark loss is 1.32 pp at and 0.45 pp at , so decode uses on both models.
Depth cap and quality weights. Table 9 gives the throughput and quality of decode shedding on Qwen3-235B for each depth cap with quality weights, and for without them. Caps of give a smaller decode gain than no cap. A cap of gives the same gain as no cap. LiveCodeBench accuracy shows no monotone trend in . A depth cap therefore brings no benefit, and decode runs without one. At , setting every quality weight to one leaves the active-expert count on the busiest rank unchanged. LiveCodeBench then drops by 1.49 pp, against 0.45 pp with the quality weights. The quality weights therefore change which experts close, not how many.
Candidate width . Table 10 recomputes the prediction accuracy of Figure 3(b) offline for each . From to , every four added candidates roughly halve the missed routing weight. The decode candidate rows grow linearly with . The prefill statistic row does not depend on . Raising from 16 to 24 enlarges the candidate rows by 50% and removes 73% of the missed weight. Raising to 32 doubles the rows and removes 90%. already keeps 99.1% of the routing weight, so Qwen3-235B uses .
Table 10. Cross-layer prediction accuracy on Qwen3-235B against the candidate width , pooled over the 12 sampled layers of Figure 3(b). Top- recall is the fraction of true Top-8 experts inside the predicted Top-. Weight recall is the share of routing weight on these experts. Missed weight is the remainder. is the default on Qwen3-235B.
| 8 | 12 | 16 | 20 | 24 | 32 | |
| Top- recall | 0.866 | 0.966 | 0.987 | 0.994 | 0.997 | 0.999 |
| Weight recall | 0.903 | 0.976 | 0.991 | 0.996 | 0.998 | 0.999 |
| Missed weight (%) | 9.7 | 2.4 | 0.92 | 0.45 | 0.25 | 0.095 |
Histogram bins and the EP degree . Table 11 replays the prefill prices offline on captured router scores, which extends the measured range of . Native imbalance grows quickly with , because each rank holds fewer experts, and RankCast still removes about half of the excess at . The bin count hardly matters. Up to , and give the same imbalance to within 0.012 on Qwen3.5-397B. The exchanged statistic row stays small, 8 KiB at with and 32 KiB at with . It rides on the existing notify_dispatch message, so it adds no synchronization. Each rank computes its price from the summed histogram in a fixed number of steps, with no iteration between ranks.
References
- [1]Yushi Bai, Shangqing Tu, Jiajie Zhang, Hao Peng, Xiaozhi Wang, Xin Lv, Shulin Cao, Jiazhen Xu, Lei Hou, Yuxiao Dong, Jie Tang, and Juanzi Li. LongBench v2: Towards deeper understanding and reasoning on realistic long-context multitasks. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 3639–3664, 2025. doi: 10.18653/v1/2025.acl-long.183. URL https://aclanthology.org/2025.acl-long.183/.DOI
- [2]Yutian Chen, Cong Li, Yucheng Wang, and Ming Wei. MoonEP: A perfectly balanced expert parallelism library via dynamic redundant experts. Software repository, 2026. URL https://github.com/MoonshotAI/MoonEP. Accessed 2026-08-09.
- [3]DeepSeek-AI. DeepSeek-V3 technical report. arXiv preprint arXiv:2412.19437, 2024. URL https://arxiv.org/abs/2412.19437.
- [4]DeepSeek-AI. EPLB: Expert parallelism load balancer. Software repository, 2025. URL https://github.com/deepseek-ai/EPLB. Accessed 2026-08-09.
- [5]DeepSeek-AI. DeepSeek-V4: Towards highly efficient million-token context intelligence. arXiv preprint arXiv:2606.19348, 2026. URL https://arxiv.org/abs/2606.19348.
- [7]Aryo Pradipta Gema, Joshua Ong Jun Leang, Giwon Hong, Alessio Devoto, Alberto Carlo Maria Mancino, Rohit Saxena, Xuanli He, Yu Zhao, Xiaotang Du, Mohammad Reza Ghasemi Madani, Claire Barale, Robert McHardy, Joshua Harris, Jean Kaddour, Emile Van Krieken, and Pasquale Minervini. Are we done with MMLU? In Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pp. 5069–5096, 2025. doi: 10.18653/v1/2025.naacl-long.262. URL https://aclanthology.org/2025.naacl-long.262/.DOI
- [8]Seokjin Go and Divya Mahajan. MOETuner: Optimized mixture of expert serving with balanced expert placement and token routing. arXiv preprint arXiv:2502.06643, 2025. URL https://arxiv.org/abs/2502.06643.
- [9]Vima Gupta, Jae Hyung Ju, Kartik Sinha, Ada Gavrilovska, and Anand Padmanabha Iyer. Lynx: Enabling efficient MoE inference through dynamic batch-aware expert selection. arXiv preprint arXiv:2411.08982, 2024. URL https://arxiv.org/abs/2411.08982.
- [10]Yu Han, Lehan Pan, Jie Peng, Ziyang Tao, Hanqi Zhu, Wuyang Zhang, and Yanyong Zhang. GRACE-MoE: Grouping and replication with locality-aware routing for efficient distributed MoE inference. arXiv preprint arXiv:2509.25041, 2025. URL https://arxiv.org/abs/2509.25041.
- [11]Shwai He, Weilin Cai, Jiayi Huang, and Ang Li. Capacity-aware inference: Mitigating the straggler effect in mixture of experts. In The Fourteenth International Conference on Learning Representations, 2026. URL https://openreview.net/forum?id=LuYFpySWA2.arxiv.org/abs/2503.05066
- [12]Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the MATH dataset. In Proceedings of the Neural Information Processing Systems Track on Datasets and Benchmarks, volume 1, 2021. URL https://datasets-benchmarks-proceedings.neurips.cc/paper/2021/hash/be83ab3ecd0db773eb2dc1b0a17836a1-Abstract-round2.html.
- [13]Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. RULER: What’s the real context size of your long-context language models? In First Conference on Language Modeling, 2024. URL https://openreview.net/forum?id=kIoBbc76Sy.arxiv.org/abs/2404.06654
- [14]Naman Jain, King Han, Alex Gu, Wen-Ding Li, Fanjia Yan, Tianjun Zhang, Sida Wang, Armando Solar-Lezama, Koushik Sen, and Ion Stoica. LiveCodeBench: Holistic and contamination free evaluation of large language models for code. In The Thirteenth International Conference on Learning Representations, 2025. URL https://openreview.net/forum?id=chfJUYC3iL.arxiv.org/abs/2403.07974
- [15]Albert Q. Jiang, Alexandre Sablayrolles, Antoine Roux, Arthur Mensch, Blanche Savary, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, et al. Mixtral of experts. arXiv preprint arXiv:2401.04088, 2024. URL https://arxiv.org/abs/2401.04088.
- [16]Kimi Team. Kimi K3: Open frontier intelligence. arXiv preprint arXiv:2607.24653, 2026. URL https://arxiv.org/abs/2607.24653.
- [18]Jiamin Li, Yimin Jiang, Yibo Zhu, Cong Wang, and Hong Xu. Accelerating distributed MoE training and inference with Lina. In 2023 USENIX Annual Technical Conference (USENIX ATC 23), pp. 945–959, 2023. URL https://www.usenix.org/conference/atc23/presentation/li_jiamin.
- [19]Yan Li, Zhenyu Zhang, Zhengang Wang, Pengfei Chen, and Pengfei Zheng. Semantic parallelism: Redefining efficient MoE inference via model-data co-scheduling. In The Fourteenth International Conference on Learning Representations, 2026. URL https://openreview.net/forum?id=MSHPrMpIHz.arxiv.org/abs/2503.04398
- [20]Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, et al. Competition-level code generation with AlphaCode. Science, 378(6624):1092–1097, 2022. doi: 10.1126/science.abq1158.DOI
- [21]Hunter Lightman, Vineet Kosaraju, Yura Burda, Harri Edwards, Bowen Baker, Teddy Lee, Jan Leike, John Schulman, Ilya Sutskever, and Karl Cobbe. Let’s verify step by step. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=v8L0pN6EOi.arxiv.org/abs/2305.20050
- [22]LiveCodeBench Team. LiveCodeBench release v5. Official benchmark release, 2025. URL https://github.com/LiveCodeBench/LiveCodeBench.
- [23]Mathematical Association of America. 2025 American Invitational Mathematics Examination (AIME I and II). Annual mathematics competition, 2025. URL https://maa.org/maa-invitational-competitions/.
- [24]Meituan LongCat Team. LongCat-Flash technical report. arXiv preprint arXiv:2509.01322, 2025. URL https://arxiv.org/abs/2509.01322.



