bf16_absmax

Function bf16_absmax 

Source
pub fn bf16_absmax(
    gpu: &dyn GpuBackend,
    kernel: KernelHandle,
    data: DevicePtr,
    out_max: DevicePtr,
    n_elems: u32,
    stream: u64,
) -> Result<()>
Expand description

Compute max absolute value of a BF16 buffer into a device-side f32.

Used for FP8 KV cache online scale calibration: accumulates max |K| and max |V| during warmup tokens. The output f32 is updated via atomicMax, so the caller must initialize it to 0.0 before the first call.

Kernel: bf16_absmax(data, out_max, n_elems) Grid: (ceil(n_elems / (256*2)), 1, 1) Block: (256, 1, 1)