Skip to main content

Module quant

Module quant 

Source
Expand description

Weight quantization primitives: INT8/INT4 affine quantization (affine, pack4) and F8_E4M3/F8_E5M2 (fp8), each parameterized by a Granularity.

Re-exports§

pub use affine::AffineParams;
pub use affine::QuantizedAffine;
pub use affine::dequantize_affine;
pub use affine::quantize_affine;
pub use fp8::Fp8Variant;
pub use fp8::QuantizedFp8;
pub use fp8::dequantize_fp8;
pub use fp8::f8_to_f32;
pub use fp8::f32_to_f8;
pub use fp8::quantize_fp8;
pub use granularity::Granularity;

Modules§

affine
Affine (scale + zero-point) integer quantization, shared by the INT8 and INT4 schemes – INT4 just runs this with bits: 4 and then nibble-packs the result (see crate::quant::pack4).
fp8
F8_E4M3/F8_E5M2 weight quantization.
granularity
How many independent scale/zero-point pairs a quantized tensor gets.
pack4
INT4 nibble packing.

Enums§

Scheme
Which quantization scheme to apply to a tensor.

Functions§

compute_groups
Computes the flat-index -> group-id table for a tensor of shape under granularity, and the resulting group count. Quantizing functions in this module compute and use this internally; it’s exposed so callers reconstructing a quantized tensor (e.g. crate::validate, or an external consumer of teeny-quant’s output) can recompute the same element -> group mapping without duplicating the grouping logic.