Packing API¶
Bit packing utilities for K/V cache tensors.
packed_length ¶
Return the number of bytes needed for packed unsigned values.
Source code in turboquant/packing/bits.py
pack_unsigned ¶
Pack unsigned integer values along the last dimension.
The last dimension is encoded as a bitstream with little-endian bit order inside each byte. Values must be in the range [0, 2**bits).
Source code in turboquant/packing/bits.py
unpack_unsigned ¶
Unpack unsigned integer values from the last packed dimension.
Source code in turboquant/packing/bits.py
pack_k4 ¶
unpack_k4 ¶
pack_k3 ¶
unpack_k3 ¶
pack_k2 ¶
unpack_k2 ¶
pack_v4 ¶
unpack_v4 ¶
pack_v2 ¶
unpack_v2 ¶
pack_v3 ¶
unpack_v3 ¶
pack_sign_bits ¶
Pack sign values into one bit each.
Accepted inputs are bool, {0, 1}, or {-1, 1}. The unpacked form is bool.
Source code in turboquant/packing/bits.py
unpack_sign_bits ¶
tensor_nbytes ¶
packed_nbytes ¶
Return storage bytes for packing the last dimension of a shape.