veloxquant_mlx.quantizers.base module¶
Quantizer construction entry point: QuantizerFactory.
Provides the single sanctioned way to instantiate a fixed-bit-width KV
quantizer (QJL, TurboQuant MSE/Prod, PolarQuant, …) by algorithm name,
validating shared preconditions (power-of-two dimension, bit-width >= 1)
before dispatching to the class registered under that name in
QuantizerRegistry.
- class veloxquant_mlx.quantizers.base.QuantizerFactory[source]¶
Bases:
objectFactory for creating Quantizer instances via the QuantizerRegistry.
All quantizer construction should go through this factory.
Example:
q = QuantizerFactory.create("qjl", d=128, m=128, seed=42) q = QuantizerFactory.create("turboquant_mse", d=128, b=2, seed=42) q = QuantizerFactory.create("turboquant_prod", d=128, b=3, m=128, seed=42) q = QuantizerFactory.create("polar", d=128, b=2, seed=42)
- static create(method, d, b=2, m=None, seed=42, store=None, **kwargs)[source]¶
Instantiate a Quantizer by method name.
- Parameters:
method (
Literal['qjl','turboquant_mse','turboquant_prod','polar']) – Algorithm name registered in QuantizerRegistry.d (
int) – Vector dimension.b (
int) – Bit-width (default 2).m (
int|None) – JL projection dimension (default = d for QJL methods).seed (
int) – Random seed.store (
ArtifactStore|None) – ArtifactStore for loading precomputed artifacts. If None, artifacts are generated on-the-fly.**kwargs (
Any) – Additional keyword arguments forwarded to the quantizer.
- Return type:
- Returns:
Configured Quantizer instance.
- Raises:
QuantizerConfigError – If parameters are invalid.
KeyError – If method is not registered.