Provider Interface#

This module defines the abstract base classes that all quantization providers must implement.

If you are building a custom quantization strategy or extending Qwix, you will implement the QuantizationProvider interface.

class qwix.QuantizationProvider(rules: Sequence[QuantizationRule])[source]#

Interface for model integration.

A provider can be either explicitly called by model authors, or implicitly injected into the model by using interception.py.

get_intercept_map() dict[str, Callable[[...], Any]][source]#

Returns the intercept map for interception.wrap_func_intercepted.

process_model_inputs(model: Any, model_args: Sequence[Any], model_kwargs: dict[str, Any]) tuple[Any, Sequence[Any], dict[str, Any]][source]#

Process the model and its inputs before it is called.

process_model_output(method_name: str, model_output: Any) Any[source]#

Process the model output before it is returned.

class qwix.QuantizationRule(*, module_path: str = '.*', op_names: Collection[str] = (), weight_qtype: str | type[Any] | dtype | SupportsDType | None = None, act_qtype: str | type[Any] | dtype | SupportsDType | None = None, tile_size: int | float | None = None, act_static_scale: bool | None = None, weight_calibration_method: str = 'absmax', act_calibration_method: str | None = None, act_batch_axes: Collection[int] = (0,))[source]#

Quantization rules that match and configure the quantization behavior.