Papers
Topics
Authors
Recent
Search
2000 character limit reached

Hard Top-k Routing Techniques

Updated 3 December 2025
  • Hard top-k routing is a discrete selection process that chooses exactly k top candidates under combinatorial and capacity constraints in applications like Mixture-of-Experts and route planning.
  • It employs strategies such as intra-GPU rectification and A*-style search to mitigate overflow and vacancy issues in both deep learning and graph optimization contexts.
  • Recent advances demonstrate improved token utilization and rapid sub-second route planning, balancing optimality, speed, and resource management.

Hard top-k routing refers to the class of combinatorial selection and allocation strategies in which, given a set of candidates (such as experts in neural MoE models or vertices in a network), exactly kk top-scoring or otherwise preferred options are chosen for each instance, subject to various constraints (such as capacity or cost). This paradigm arises in sparse deep learning architectures—most notably Mixture-of-Experts (MoE) models—and in combinatorial optimization for route planning on graphs, as exemplified by the top-k route search and KOSR (top-k optimal sequenced routes) literature. Hardness stems from the discrete and combinatorial nature of selection, non-convex constraints, and requirements for optimality or near-optimality, often compounded by per-selection limitations such as per-node expert token quotas, global budgets, or monotone submodular set objectives.

1. Definition and Scope of Hard Top-k Routing

Hard top-k routing encompasses problems and algorithms where, for each input instance (such as a token in MoE or a node in routing), the algorithm selects exactly kk recipients (experts, outgoing links, or next hops) based on some scoring function. Formally, for a set of scores aija_{ij} over NN instances and MM options, each instance ii is routed to the kk highest-scoring jj—the top-kk selection—often under additional per-option capacity or global cost constraints.

The “hardness” of top-k routing stems from its combinatorial search structure, the potential for conflicts under mutual constraints (such as overflows in MoE or budget/visit constraints in routing), and the impossibility of relaxing the problem into convex optimization as would be feasible in “soft” routing schemes. Key applications include:

2. Hard Top-k Routing in Mixture-of-Experts Architectures

In sparse MoE models, hard top-k routing governs the assignment of each token representation xiRdx_i\in\mathbb{R}^d to exactly kk0 experts chosen from kk1 candidates. The standard hard top-k gating procedure consists of:

  • Computing scores kk2 for each expert kk3.
  • Selecting kk4 as the set of size kk5 corresponding to the top-kk6 kk7 for each token kk8.
  • Computing normalized gates kk9 for aija_{ij}0 via softmax over aija_{ij}1; aija_{ij}2 otherwise.
  • Aggregating expert outputs as aija_{ij}3.

Under capacity constraint aija_{ij}4 per expert (aija_{ij}5), hard top-k routing induces two inefficiencies:

  • Overflow (dropped tokens): aija_{ij}6 tokens routed to expert aija_{ij}7; surplus are dropped, leading to ineffective compute utilization and potential accuracy drop.
  • Vacancy (padding): aija_{ij}8 triggers padding (often with zeros), wasting compute and harming model utility.

To address these, “Rectify-Router” introduces:

  • Intra-GPU Rectification: Reassign overflowed tokens to alternative experts residing on the same GPU, provided they have spare capacity, avoiding costly inter-GPU communication and maximizing local utilization.
  • Fill-in Rectification: Fill vacant slots at underutilized experts with next-best tokens (those ranking aija_{ij}9-th in their preference lists), increasing effective compute utilization and restoring gradient flow to informative tokens.

Combined, these methods recover nearly all “wasted” compute without altering expert capacity or incurring extra interconnect cost. Experimental results indicate notable increases in top-1 routing accuracy (from NN0 to NN1 on LLaMA-MoE 7B), with NN2 training speed penalty and NN3 inference slowdown (Zeng et al., 2024).

3. Combinatorial Hardness and Routing on Graphs

Hard top-k routing generalizes classic combinatorial problems such as path planning with attribute or order constraints. The top-k optimal sequenced routes (KOSR) problem, for example, seeks the NN4 least-cost routes from source NN5 to destination NN6 that visit one vertex in each of a prescribed category sequence NN7 in order (Liu et al., 2018). This extends classic single-best-sequenced routing to the top-NN8 regime and is NP-hard when the category visitation order is unconstrained.

Practical algorithms for hard top-k routing in graphs include:

  • Dominance-pruning based expansion (PruningKOSR): Avoids redundant exploration by maintaining, for each partial route terminating at a vertex, only those not strictly dominated (i.e., lower cost) by other partials of the same length and endpoint. This allows the search space to contract from full NN9 blowup to the scale of MM0.
  • A*-style search with admissible heuristic (StarKOSR): Embeds the above in an A* search prioritizing completions with minimum estimated cost-to-go, leveraging two-hop labeling for constant-time distance queries.

Performance evaluations on large road networks show that StarKOSR reduces top-k search on graphs with MM1–MM2 vertices and MM3 from hour-scale to subsecond query times, outpacing baselines by several orders of magnitude (Liu et al., 2018).

4. Submodular and Feature-aware Generalizations

In route recommendation and planning with explicit diversity, feature matching, or user personalization objectives, hard top-k routing is further complicated by set-based, submodular utility functions. The “top-k route search through submodularity modeling of recurrent POI features” problem formalizes route selection as the maximization of a monotone submodular gain (such as diversity of visited features) under cost or length constraints (Liang et al., 2017). The gain is defined, for a route as a set of POIs MM4, as:

MM5

with MM6 submodular and monotone for each feature MM7, and MM8 user-supplied weights.

Exact algorithms such as PACER employ:

  • Stateful enumeration: Each compact state is defined by a subset of candidate POIs; store for each such set the best gain and costs associated with particular endpoints.
  • Two-layer pruning: (i) Cost-dominance pruning—discard partials with higher cost for the same visited set and endpoint; (ii) Gain upper-bound pruning—if the best-completable gain from a state cannot beat the current MM9-th best, prune further expansion using a continuous greedy bound on the remaining budget.
  • Heuristic variants (PACER-SC, greedy insertion) trade off optimality for speed in large candidate sets, achieving near-optimal results with ii0–ii1 runtime saving for ii2 and achieving solution qualities within 95–99% of optimal.

This submodular route-search framework provides provable optimality for small to moderate budget queries and near-optimality at scale (Liang et al., 2017).

5. Complexity, Scalability, and Trade-offs

The fundamental obstacle in hard top-k routing problems is the combinatorial explosion in candidate selections and assignments:

Scenario Baseline Complexity Advanced Algorithmic Complexity Typical Empirical Speedup
MoE Sparse Routing (N tokens, M experts) ii3 gating + all-to-all + ii4 per expert ii5 local select, ii6 local rectification ii7 overhead for full utilization (Zeng et al., 2024)
KOSR on Graphs (l categories, ii8 per cat.) ii9 worst case kk0 with pruning (Liu et al., 2018) kk1–kk2 faster
Submodular Routing (n POIs, p max route length) kk3 (brute force) kk4 with PACER kk5–kk6 (PACER+2 vs BF) (Liang et al., 2017)

Empirically, applying dominance and upper-bound pruning, as well as local rectification (for hard capacity), retains almost all the possible “value” (accuracy in MoE, gain in route search), while transforming intractable problems to those solvable in milliseconds to seconds for real-world data sizes.

6. Practical Considerations and Open Questions

Hard top-k routing solutions, while effective in their designated regimes, raise several open technical questions and avenues for further research:

  • Resource and locality-aware scheduling: In MoE, extending intra-GPU rectification to broader topologies, such as inter-rack communication where cost is still low, could further improve utilization (Zeng et al., 2024).
  • Adaptive and dynamic top-k selection: Recent work moves beyond static kk7 to adaptive or learnable kk8 per instance, though the detailed algorithms for such schemes are addressed outside the scope of the current hard static paradigm [(Yue et al., 2024), abstract].
  • Capacity-aware gating and fair allocation: Endowing routing networks with the ability to dynamically predict and accommodate variable slot availability could further reduce overflows and vacancies (Zeng et al., 2024).
  • Submodular knapsack and personalized diversity: Combining monotonicity and diminishing returns in set objectives complicates route enumeration and suggests a need for further theoretical work on scalable (approximate) search or amortized index-based approaches (Liang et al., 2017).
  • Scalability to larger or more dynamic contexts: Cache size, two-hop label pre-processing for graphs, and routing overhead for massive (or rapidly evolving) networks remain bottlenecks, suggesting potential for parallel, distributed, or streaming algorithmic extensions.

7. Representative Algorithms and Empirical Results

Key algorithmic contributions and experimental findings include:

  • Rectify-Router for MoE top-k routing: Recovers nearly 100% of expert token utilization, increases top-1 routing accuracy by 4.7%, with negligible runtime and no extra parameter cost (Zeng et al., 2024).
  • StarKOSR for top-k sequenced routes: Achieves sub-second top-30 answer times on graphs with kk9 vertices, with pruned search space two to four orders of magnitude smaller than full enumeration (Liu et al., 2018).
  • PACER and variants for submodular POI routing: PACER+2 achieves optimal top-jj0 on city-scale queries within seconds for moderate budgets, PACER-SC and GR provide near-optimal answers sub-second for larger-scale or more relaxed constraints, with systematic analysis of trade-offs between speed and gain (Liang et al., 2017).

Taken together, the evolution of hard top-k routing methodology links the discrete resource allocation perspective from deep learning with combinatorial optimization in graphs and submodular maximization, yielding unified insights into efficient, scalable selection under strict allocation constraints.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Hard Top-k Routing.