moe_weighted_sum_blend_prefill

Function moe_weighted_sum_blend_prefill 

Source
pub fn moe_weighted_sum_blend_prefill(
    gpu: &dyn GpuBackend,
    kernel: KernelHandle,
    output: DevicePtr,
    expert_out: DevicePtr,
    expert_weights: DevicePtr,
    shared_out: DevicePtr,
    input: DevicePtr,
    gate_weight: DevicePtr,
    hidden: u32,
    top_k: u32,
    k: u32,
    num_tokens: u32,
    stream: u64,
) -> Result<()>
Expand description

2026-09-25: Per token t: output[t] = sum_e expert_weights[t*top_k+e] * expert_out[t*top_k+e] + sigmoid(dot(input[t], gate_weight)) * shared_out[t]. expert_out is [num_tokens * top_k, hidden] BF16, expert_weights [num_tokens * top_k] f32, input [num_tokens, k] BF16 and gate_weight the shared-expert gate [1, k] BF16.