dense_gemm_tc_scaled_acc

Function dense_gemm_tc_scaled_acc 

Source
pub fn dense_gemm_tc_scaled_acc(
    gpu: &dyn GpuBackend,
    kernel: KernelHandle,
    input: DevicePtr,
    weight: &DenseWeight,
    output: DevicePtr,
    m: u32,
    n: u32,
    k: u32,
    scale: f32,
    stream: u64,
) -> Result<()>
Expand description

output[m, n] += scale * bf16(input[m, k] @ weight[n, k]^T) in ONE pass.

The fused epilogue of dense_gemm_tc, for LoRA’s expand+fold. The unfused pair (GEMM into scratch, then scaled_add) writes an [m, n] tensor, reads it back, and read-modify-writes the destination; this does the last of those only. On a 27B prefill with n = intermediate = 17408 that scratch round-trip dominated — it measured as a 5.6x prefill slowdown with a LoRA adapter resident.

BIT-IDENTICAL to the unfused pair: the kernel rounds the delta to BF16 before applying scale, exactly as storing to a BF16 scratch and running bf16_scaled_add over it did.