autonas
Entrypoints for AutoNAS mode.
Classes
A class to handle the monkey patching of the model for automode. |
|
An iterative searcher that uses an evolutionary algorithm to optimize the subnet config. |
|
Base class for iterative search algorithms. |
|
An iterative searcher that samples subnets randomly. |
Functions
Convert search space for AutoNAS mode with correct patch manager. |
|
Convert given model into a search space. |
|
Export a subnet configuration of the search space to a regular model. |
|
Restore search space for AutoNAS mode with correct patch manager. |
|
Restore & export the subnet configuration of the search space to a regular model. |
|
Restore a search space from the given model. |
|
Update subnet config to current subnet config of model. |
- class AutoNASPatchManager
Bases:
PatchManager
A class to handle the monkey patching of the model for automode.
- property sample_during_training: bool
Indicates whether we should sample a new subnet during training.
- class EvolveSearcher
Bases:
IterativeSearcher
An iterative searcher that uses an evolutionary algorithm to optimize the subnet config.
- after_step()
Update population after each iterative step.
- Return type:
None
- before_search()
Set the lower bound of the constraints to 0.85 * upper bound before search.
- Return type:
None
- before_step()
Update candidates and population before each iterative step.
- Return type:
None
- candidates: List[Dict[str, Any]]
- property default_search_config: Dict[str, Any]
Default search config contains additional algorithm parameters.
- property default_state_dict: Dict[str, Any]
Return default state dict.
- population: List[Dict[str, Any]]
- sample()
Sampling a new subnet involves random sampling, mutation, and crossover.
- Return type:
Dict[str, Any]
- class IterativeSearcher
Bases:
BaseSearcher
,ABC
Base class for iterative search algorithms.
- after_search()
Select best model.
- Return type:
None
- after_step()
Run after each iterative step.
- Return type:
None
- before_search()
Ensure that the model is actually configurable and ready for eval.
- Return type:
None
- before_step()
Run before each iterative step.
- Return type:
None
- best: Dict[str, Any]
- best_history: Dict[str, Any]
- candidate: Dict[str, Any]
- constraints_func: ConstraintsFunc
- property default_search_config: Dict[str, Any]
Get the default config for the searcher.
- property default_state_dict: Dict[str, Any]
Return default state dict.
- early_stop()
Check if we should early stop the search if possible.
- Return type:
bool
- history: Dict[str, Any]
- iter_num: int
- num_satisfied: int
- run_search()
Run iterative search loop.
- Return type:
None
- run_step()
The main routine of each iterative step.
- Return type:
None
- abstract sample()
Sample and select new sub-net configuration and return configuration.
- Return type:
Dict[str, Any]
- samples: Dict[str, Any]
- sanitize_search_config(config)
Sanitize the search config dict.
- Parameters:
config (Dict[str, Any] | None) –
- Return type:
Dict[str, Any]
- class RandomSearcher
Bases:
IterativeSearcher
An iterative searcher that samples subnets randomly.
- sample()
Random sample new subset during each steo.
- Return type:
Dict[str, Any]
- convert_autonas_searchspace(model, config)
Convert search space for AutoNAS mode with correct patch manager.
- Parameters:
model (Module) –
config (ModeloptBaseConfig) –
- Return type:
Tuple[Module, Dict[str, Any]]
- convert_searchspace(model, config, patch_manager_type)
Convert given model into a search space.
- Parameters:
model (Module) –
config (ModeloptBaseConfig) –
patch_manager_type (Type[PatchManager]) –
- Return type:
Tuple[Module, Dict[str, Any]]
- export_searchspace(model, config)
Export a subnet configuration of the search space to a regular model.
- Parameters:
model (Module) –
config (ExportConfig) –
- Return type:
Tuple[Module, Dict[str, Any]]
- restore_autonas_searchspace(model, config, metadata)
Restore search space for AutoNAS mode with correct patch manager.
- Parameters:
model (Module) –
config (ModeloptBaseConfig) –
metadata (Dict[str, Any]) –
- Return type:
Module
- restore_export(model, config, metadata)
Restore & export the subnet configuration of the search space to a regular model.
- Parameters:
model (Module) –
config (ExportConfig) –
metadata (Dict[str, Any]) –
- Return type:
Module
- restore_searchspace(model, config, metadata, patch_manager)
Restore a search space from the given model.
- Parameters:
model (Module) –
config (ModeloptBaseConfig) –
metadata (Dict[str, Any]) –
patch_manager (Type[PatchManager]) –
- Return type:
Module
- update_autonas_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