moe_build_tile_worklist

Function moe_build_tile_worklist 

Source
pub fn moe_build_tile_worklist(
    gpu: &dyn GpuBackend,
    kernel: KernelHandle,
    expert_offsets: DevicePtr,
    weight_ptrs: DevicePtr,
    worklist: DevicePtr,
    total_tiles: DevicePtr,
    num_experts: u32,
    n_tiles: u32,
    m_tile: u32,
    stream: u64,
) -> Result<()>
Expand description

2026-09-25: Build the compacted work-list for the grouped-GEMM grid: one item per (expert, m-tile, n-tile) of every expert that has rows and a non-NULL weight pointer, experts in ascending order. One CTA; thread 0 writes worklist[2w] = expert, worklist[2w + 1] = (m-tile index << 6) | n-tile index, and total_tiles[0] = w.

n_tiles is ceil(N / 64) and m_tile is 128, as PM4_N_TILE and PM4_M_TILE in moe_fp8_grouped_gemm.cu. The n-tile index has 6 bits, so n_tiles must be at most 64; the kernel asserts it. expert_offsets is [num_experts + 1] and weight_ptrs [num_experts]; an expert whose pointer is NULL gets no items.

No event orders this before the grouped GEMM that reads the list, so launch that GEMM on the same stream.