Expand description
INT4 nibble packing.
safetensors 0.7 has no native I4/U4 dtype, so packed INT4 tensors are stored as plain
U8. Packing layout (this crate’s own convention – not bit-for-bit compatible with any
particular GPTQ/AWQ int32-packing scheme, which vary across implementations and versions):
two consecutive elements in row-major order share one byte, the first in the low nibble and
the second in the high nibble, each a 4-bit two’s-complement value in -8..=7. A tensor with
an odd element count gets one trailing byte whose high nibble is unused padding (0). The
packed tensor’s logical shape and element count are recorded separately in the
quantization_config metadata (see crate::format) since the packed U8 tensor’s own
shape ([ceil(n / 2)]) doesn’t reflect it.