puzzletron_nas_plugin
Puzzletron NAS plugin for the Modelopt framework (based on Puzzle algorithm: https://arxiv.org/abs/2411.19146).
It is used by mtn.convert() to convert a model from HF format to Puzzletron heterogeneous format + do pruning scoring and save pruned checkpoints, and by mtn.search() to perform the MIP-based NAS search.
Classes
Descriptor for the Puzzletron mode. |
|
Runs NAS search for the Puzzletron mode. |
Functions
Restore is not needed for the puzzletron mode as we are not saving any model state |
- ModeloptConfig PuzzletronConfig
Bases:
ModeloptBaseConfigConfiguration for Puzzletron NAS algorithm.
Show default config as JSON
- Default config (JSON):
{ "input_model_path": "", "hydra_config_dir": "", "hydra_config_name": "", "puzzle_dir": "", "dataset_path": "" }
- field dataset_path: str
- field hydra_config_dir: str
- field hydra_config_name: str
- field input_model_path: str
- field puzzle_dir: str
- class PuzzletronDescriptor
Bases:
ModeDescriptorDescriptor for the Puzzletron mode.
- property config_class: type[ModeloptBaseConfig]
Configuration class for this mode.
- property convert: Callable[[Module, ModeloptBaseConfig], tuple[Module, dict[str, Any]]] | Callable[[Module, ModeloptBaseConfig, Any], tuple[Module, dict[str, Any]]]
Entrypoint to convert a model.
- property export_mode: str | None
The mode that corresponds to the export mode. For now, this will be a no-op as there is no modelopt’s concept of search space defined for the puzzletron algorithm.
- property name: str
String identifier for this mode.
- property restore: Callable[[Module, ModeloptBaseConfig, dict[str, Any]], Module]
Entrypoint to restore a model.
- property search_algorithm: type[BaseSearcher]
Return the associated searcher implementation.
- class PuzzletronModel
Bases:
Module
- class PuzzletronSearcher
Bases:
BaseSearcherRuns NAS search for the Puzzletron mode.
- property default_state_dict: dict[str, Any]
Not needed for the puzzletron mode as we are not saving any model state
- run_search()
- Return type:
None
- convert_puzzletron_model(model, config)
Convert the model from HF format to AnyModel format.
Score the pruning activations.
Prune the model and save pruned checkpoints
The output of this step will be used by mnt.search() to perform the NAS search.
- Parameters:
model (Module)
config (PuzzletronConfig)
- Return type:
tuple[Module, dict[str, Any]]
- restore_puzzletron_model(model, config, metadata)
Restore is not needed for the puzzletron mode as we are not saving any model state
- Parameters:
model (Module)
config (PuzzletronConfig)
metadata (dict[str, Any])
- Return type:
Module