pub fn apply_expert_lora_sorted(
gpu: &dyn GpuBackend,
kernels: &LoraKernels,
layer: &ExpertLoraLayer,
proj: ExpertProj,
expert_offsets_host: &[u32],
x: DevicePtr,
base_out: DevicePtr,
max_rows: u32,
lora_xa: DevicePtr,
lora_delta: DevicePtr,
stream: u64,
) -> Result<()>Expand description
Fold proj’s per-expert LoRA deltas onto the SORTED grouped-GEMM output.
x = the projection’s sorted input ([total_expanded, pair.k_in]),
base_out = the projection’s sorted output ([total_expanded, pair.n_out],
modified in place). expert_offsets_host is the D2H copy of the device
expert_offsets ([num_experts + 1]). One apply_lora_delta(m = rows) per
adapted expert, over that expert’s contiguous row block — byte-identical to
rows sequential m=1 folds. Only experts with a pair for proj AND
non-zero routed rows launch.