Skip to main content

evaluate_topk

Function evaluate_topk 

pub fn evaluate_topk<C>(
    context: &mut C,
    schedule: Schedule,
    length: usize,
    k: usize,
    warmups: usize,
    samples: usize,
) -> Result<(GeneratedShader, GpuEvaluation), ForgeError>
where C: OracleContext,
Expand description

Cross-backend differential-oracle evaluation for the top-k kernel against topk_cpu (plan §7). Generic over OracleContext — the same code runs on wgpu and CUDA; only OracleContext::run_kernel differs.

block_size is fixed to schedule.workgroup_size; the dispatch launches one workgroup per block. The output buffer is sized to num_blocks * k, not the input length. Seeds, bindings, dispatch sizing and tolerance match the prior wgpu/evaluate_topk_cuda paths.