Expand description
INT4 weight quantization/dequantization, bit-for-bit parity with Python quantize.py.
Scheme: symmetric group-wise INT4, group_size=32 along input axis. Scale = max(|group|) / 7.0, clamped >= 1e-8. Values packed as two nibbles per byte: low nibble = even row, high nibble = odd row. Stored signed as two’s-complement 4-bit: range [-8, 7].
Data layout: row-major (pair-major) — data[pair * out_feat + o].
This makes the inner loop over output features contiguous, enabling AVX2
auto-vectorization in matvec_inner_avx2 and plain scalar vectorization elsewhere.
Structs§
- Quantized
Weight - Packed INT4 weight tensor with per-group f32 scales.