mode

This module contains the mode descriptor for the quantization mode.

Classes

QuantizeExportModeDescriptor

Class to describe the export of quantization mode.

QuantizeModeDescriptor

Class to describe the "quant" mode.

class QuantizeExportModeDescriptor

Bases: _ModeDescriptor

Class to describe the export of quantization mode.

Note that this mode is just a placeholder to throw an error since we don’t support exporting quantized models right now. It is used to properly indicate that the quantize mode does require an export mode if we ever wanted to do chaining/stacking of modes with it.

property config_class: Type[ModeloptBaseConfig]

Specifies the config class for the mode.

property convert: Callable[[Module, ModeloptBaseConfig], Tuple[Module, Dict[str, Any]]]

The mode’s entrypoint for converting a model.

property is_export_mode: bool

Specifies whether the mode is an export mode.

property name: str

Returns the value (str representation) of the mode.

property restore: Callable[[Module, ModeloptBaseConfig, Dict[str, Any]], Module]

The mode’s entrypoint for restoring a model.

class QuantizeModeDescriptor

Bases: _ModeDescriptor

Class to describe the "quant" mode.

The properties of this mode can be inspected via the source code.

property config_class: Type[ModeloptBaseConfig]

Specifies the config class for the mode.

property convert: Callable[[Module, ModeloptBaseConfig], Tuple[Module, Dict[str, Any]]]

The mode’s entrypoint for converting a model.

property export_mode: str | None

The mode that corresponds to the export mode of this mode.

property name: str

Returns the value (str representation) of the mode.

property next_modes: Set[str] | None

Modes that must immediately follow this mode.

property restore: Callable[[Module, ModeloptBaseConfig, Dict[str, Any]], Module]

The mode’s entrypoint for restoring a model.

property update_for_new_mode: Callable[[Module, ModeloptBaseConfig, Dict[str, Any]], None]

The mode’s entrypoint for updating the models state before new mode.

property update_for_save: Callable[[Module, ModeloptBaseConfig, Dict[str, Any]], None]

The mode’s entrypoint for updating the models state before saving.