Skip to main content

gate_route_kernel

Function gate_route_kernel 

Source
pub fn gate_route_kernel(e: &Engine) -> Result<String, Box<dyn Error>>
Expand description

Device-router oracle at REAL geometry (devtwin lane): qwen4exp_route_topk_f32 vs host_route_softmax_topk on the SAME logits. Contract: the selection (ids AND their emitted order — the combine reads slots sequentially) is EXACT, hard fail on any mismatch; weights within a documented ULP bound (exp is the one op not bit-pinned to host libm — kernel doc), worst observed printed in the receipt. Rows include the tie batteries a random draw cannot produce: duplicate-logit groups STRADDLING the top-k boundary (weight ties resolve by index — the rule a logits-ordered top-k would get wrong), an all-equal row, and underflow rows (subnormal/zero weight ties). The renorm denominator floor is unbindable on softmax geometry (top-k sum >= k/experts — see ROUTE_DENOM_FLOOR) so it carries no arm; the twin computes the same fmaxf.