gigl.common.utils.feature_quantization.numpy_ops#

NumPy feature quantization helpers for preprocessing.

Quantization runs in the data preprocessor, where feature data is stored as CPU arrays and torch is not available. Dequantization lives in torch_ops.py because the dataloader collate path operates on torch tensors that may already be on GPU.

Functions#

quantize_ndarray(features, *, bits[, clip_min, clip_max])

Quantize a 2D float array into packed uint8 codes.

Module Contents#

gigl.common.utils.feature_quantization.numpy_ops.quantize_ndarray(features, *, bits, clip_min=None, clip_max=None)[source]#

Quantize a 2D float array into packed uint8 codes.

For multi-bit quantization, clip_min and clip_max are required and define the min-max scaling range: values are clipped to that range, scaled to [0, 2**bits - 1], rounded to integer codes, then packed into bytes.

Parameters:
  • features (jaxtyping.Float[numpy.ndarray, entities feature_dim])

  • bits (int)

  • clip_min (float | None)

  • clip_max (float | None)

Return type:

jaxtyping.UInt8[numpy.ndarray, entities packed_feature_dim]