build_ep_routing_table

Function build_ep_routing_table 

Source
pub fn build_ep_routing_table(
    gate_indices: &[u32],
    gate_weights: &[f32],
    num_tokens: usize,
    top_k: usize,
    local_expert_start: usize,
    local_expert_end: usize,
) -> EpRoutingTable
Expand description

Build EP routing table from flattened gate indices and weights.

Given the top-K expert assignments for M tokens, partitions them into local vs remote based on which rank owns each expert.

§Arguments

  • gate_indices - Flattened [M * top_k] expert indices from top-K selection
  • gate_weights - Flattened [M * top_k] routing weights from top-K selection
  • num_tokens - Number of tokens (M)
  • top_k - Number of experts per token
  • local_expert_start - First expert index owned by this rank (inclusive)
  • local_expert_end - Last expert index owned by this rank (exclusive)

§Panics

Panics if gate_indices.len() != num_tokens * top_k or gate_weights.len() != num_tokens * top_k.