Skip to main content

quant_dequant

Function quant_dequant 

Source
pub fn quant_dequant(
    x: ArrayView2<'_, f32>,
    bits: u32,
    by_row: bool,
) -> Array2<f32>
Expand description

Affine quantize→dequantize a [rows, cols] matrix at bits bits, returning the reconstructed (lossy) values. by_row = true gives each ROW its own scale (per-token, for Values); by_row = false gives each COLUMN its own scale (per-channel, for Keys). Reconstruction error per element is ≤ scale/2 of its group.