pub fn moe_lora_gather_bgmv(
gpu: &dyn GpuBackend,
kernels: &LoraKernels,
route: &MoeExpertRoute,
x: DevicePtr,
base_out: DevicePtr,
indices: DevicePtr,
row_adapter: DevicePtr,
xa: DevicePtr,
n_slots: u32,
top_k: u32,
x_gather: u32,
stream: u64,
) -> Result<()>Expand description
SOLID Incr-4: launch the DECODE-path MoE expert down fold. The unsorted,
slot-major analogue of moe_lora_grouped_down — instead of an
expert_offsets prefix sum over sorted rows, each flat (token, slot) row
gathers its expert from indices[row] (the same indices_dev the fused
expert GEMV routed on) and its base/adapt decision from
row_adapter[row / top_k] (< 0 = base skip, or DevicePtr::NULL to fold
every row on the single-active-adapter path).
x = the post-swiglu activations (silu(gate)*up, produced by the caller’s
moe_silu_mul launch into a packed [n_slots, k_in] BF16 scratch — the SAME
kernel + BF16 round the prefill fold uses, so the delta is BF16-ULP identical
to prefill). base_out = the slot-major expert_down_out ([n_slots, n_out]
BF16, folded IN PLACE before moe_weighted_sum_blend, so the router weight
multiplies base+delta). xa = the fixed-address [n_slots, max_rank] BF16
shrink scratch. The grid is EXACT (n_slots is a host constant per captured
graph) — no worst-case tiles — and all args are pointer/value-stable, so the
launch captures cleanly.
ARG ORDER is in lockstep with moe_lora_gather_bgmv.cu (cuLaunchKernel is
type-blind; keep both in sync).