Skip to main content

dequantize_q4

Function dequantize_q4 

Source
pub fn dequantize_q4<B: Backend>(
    packed: Tensor<B, 2, Int>,
    scales: Tensor<B, 2>,
    group_size: usize,
) -> Tensor<B, 2>
Expand description

Dequantizes packed 4-bit weights to f32.

  • packed: [rows, cols / 2] int tensor, byte values 0..=255 (GGUF q4_0 nibble order: low nibble = first half of the block, high nibble = second half).
  • scales: [rows, cols / group_size] f32 per-block scales.

Returns the [rows, cols] f32 weight matrix.

Panics (via shape assertions) if cols % group_size != 0; group sizes other than 32 keep the low/high split-half convention within each group (i.e. byte j of a group holds values j and j + group_size/2).