mode#

Module implementing and describing modes that can be used during the NAS convert process.

Check out mtn.convert to learn more about modes.

Classes

ExportStudentModeDescriptor

Class to describe the specific Export mode to be used with Knowledge Distillation.

KnowledgeDistillationModeDescriptor

Class to describe the Knowledge-Distillation mode.

LayerwiseKDModeDescriptor

Class to describe the Layerwise Knowledge-Distillation mode.

class ExportStudentModeDescriptor#

Bases: ModeDescriptor

Class to describe the specific Export mode to be used with Knowledge Distillation.

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]]] | Callable[[Module, ModeloptBaseConfig, Any], 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.

property save_mode_in_state: bool#

Whether the mode should be saved into the modelopt state.

class KnowledgeDistillationModeDescriptor#

Bases: ModeDescriptor

Class to describe the Knowledge-Distillation 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]]] | Callable[[Module, ModeloptBaseConfig, Any], 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 restore: Callable[[Module, ModeloptBaseConfig, dict[str, Any]], Module]#

The mode’s entrypoint for restoring a model.

property save_mode_in_state: bool#

Whether the mode should be saved into the modelopt state.

class LayerwiseKDModeDescriptor#

Bases: KnowledgeDistillationModeDescriptor

Class to describe the Layerwise Knowledge-Distillation 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]]] | Callable[[Module, ModeloptBaseConfig, Any], tuple[Module, dict[str, Any]]]#

The mode’s entrypoint for converting a model.

property name: str#

Returns the value (str representation) of the mode.