Skip to main content

route_topk

Function route_topk 

pub fn route_topk(
    gate_logits: &[f32],
    k: usize,
    norm_topk_prob: bool,
    out_indices: &mut [u16],
    out_weights: &mut [f32],
) -> Result<usize, MoeError>
Expand description

Zero-heap top-k expert selection and routing weight calculation.

Caller supplies out_indices and out_weights buffers of length >= k. Does not perform heap allocations (zero-heap in hot paths per Rule 0).