veloxquant_mlx.handlers.bit_pack_handler module¶
Handler stage that packs/unpacks codebook indices via BitPackBuffer.
Wraps veloxquant_mlx.dsa.bit_pack.BitPackBuffer as a
QuantizationHandler pipeline stage: on encode it bit-packs
ctx.indices down to b bits per element into ctx.packed_bits; on
decode it unpacks ctx.packed_bits back into ctx.indices. Typically
the last stage in an encode chain, after scalar quantization has produced
codebook indices.
- class veloxquant_mlx.handlers.bit_pack_handler.BitPackingHandler(b, d)[source]¶
Bases:
QuantizationHandlerPack codebook indices into b-bit compact storage.
- On encode:
Reads ctx.indices (batch, d) uint8. Packs each row independently using BitPackBuffer. ctx.packed_bits = packed byte array.
- On decode:
Reads ctx.packed_bits and the original n (d). Unpacks back to (batch, d) uint8 and stores in ctx.indices.
- handle(ctx)[source]¶
Pack or unpack codebook indices.
- Parameters:
ctx (
QuantizationContext) – Quantization context.- Return type:
- Returns:
Updated context.