moe_hash_route

Function moe_hash_route 

Source
pub fn moe_hash_route(
    gpu: &dyn GpuBackend,
    kernel: KernelHandle,
    gate_logits: DevicePtr,
    tid2eid: DevicePtr,
    token_id_ptr: DevicePtr,
    expert_indices: DevicePtr,
    expert_weights: DevicePtr,
    num_experts: u32,
    top_k: u32,
    normalize: bool,
    scaling_factor: f32,
    stream: u64,
) -> Result<()>
Expand description

GPU-side MoE hash routing (DeepSeek-V4 hash_moe layers).

Expert selection is a static tid2eid[token_id] lookup (frozen table); the learned gate still supplies the sqrtsoftplus scores that weight the selected experts. Mirrors moe_topk_sqrtsoftplus but with static selection instead of top-K.

Kernel: moe_hash_route(gate_logits, tid2eid, token_id_ptr, expert_indices, expert_weights, num_experts, top_k, normalize, scaling_factor) Grid: (1, 1, 1) Block: (256, 1, 1)