mixle.engines.packing module¶
Sub-byte bit-packing – genuine fp1/fp2/fp4 (and below-byte index) STORAGE compression in pure numpy.
The low-bit end of mixle’s spectrum is a storage win, not a CPU compute speedup (sub-byte arithmetic has
no native CPU support and dequant-to-fp32 is slower than fp32; that fast-dequant kernel is the Cython/C
tail). But the packing – cramming bits-wide codes into bytes – vectorizes cleanly with numpy
shifts and is what actually shrinks the bytes on disk / on the wire. Power-of-two widths {1,2,4,8} pack
exactly 8/bits codes per byte; this is the codec CodebookFormat and
the low-bit float formats use to realize their advertised compression ratio.
- pack_bits(codes, bits)[source]
Pack unsigned
codes(each< 2**bits) into auint8array,8//bitsper byte.bitsmust be a power of two in {1, 2, 4, 8} (the widths that tile a byte exactly). Little-endian within each byte: codejof a group occupies bit positions[j*bits, (j+1)*bits).
- unpack_bits(packed, bits, count)[source]
Inverse of
pack_bits(): recover the firstcountcodes as auint64array.