mode
Sparsity mode descriptor.
Classes
Class to describe the |
|
Class to define and describe sparsification based on SparseGPT. |
|
Class to define and describe magnitude-based sparsification. |
Functions
Function for converting a model to a sparsity meta-model. |
|
Export a sparse model to a regular model. |
|
Restore & export a sparse model to a regular model. |
|
Function for restoring a previously convert model to a sparsity meta-model. |
|
Update subnet config to current subnet config of model. |
- class ExportSparseModeDescriptor
Bases:
_ModeDescriptor
Class to describe the
"export_sparse"
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 is_export_mode: bool
Specifies if this 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 SparseGPTModeDescriptor
Bases:
SparseMagnitudeModeDescriptor
Class to define and describe sparsification based on SparseGPT.
- property config_class: Type[ModeloptBaseConfig]
Specifies the config class for the mode.
- property name: str
Returns the name of the mode.
- property search_algorithm: Type[BaseSearcher]
Specifies the search algorithm for the mode.
- class SparseMagnitudeModeDescriptor
Bases:
_ModeDescriptor
Class to define and describe magnitude-based sparsification.
- 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 name of the mode.
- property next_modes: Set[str] | None
Specifies the next modes for the mode.
- property restore: Callable[[Module, ModeloptBaseConfig, Dict[str, Any]], Module]
The mode’s entrypoint for restoring a model.
- property search_algorithm: Type[BaseSearcher]
Specifies the search algorithm for the mode.
- property update_for_new_mode: Callable[[Module, ModeloptBaseConfig, Dict[str, Any]], None]
The mode’s entrypoint for updating the models metadata.
- property update_for_save: Callable[[Module, ModeloptBaseConfig, Dict[str, Any]], None]
The mode’s entrypoint for updating the models metadata.
- convert_sparse_model(model, config)
Function for converting a model to a sparsity meta-model.
- Parameters:
model (Module) –
config (ModeloptBaseConfig) –
- Return type:
Tuple[Module, Dict[str, Any]]
- export_sparse(model, config)
Export a sparse model to a regular model.
- Parameters:
model (Module) –
config (ExportSparseConfig) –
- Return type:
Tuple[Module, Dict[str, Any]]
- restore_export_sparse(model, config, metadata)
Restore & export a sparse model to a regular model.
- Parameters:
model (Module) –
config (ExportSparseConfig) –
metadata (Dict[str, Any]) –
- Return type:
Module
- restore_sparse_model(model, config, metadata)
Function for restoring a previously convert model to a sparsity meta-model.
- Parameters:
model (Module) –
config (ModeloptBaseConfig) –
metadata (Dict[str, Any]) –
- Return type:
Module
- update_sparse_metadata(model, config, metadata)
Update subnet config to current subnet config of model.
- Parameters:
model (Module) –
config (ModeloptBaseConfig) –
metadata (Dict[str, Any]) –
- Return type:
None