autonas

Entrypoints for AutoNAS mode.

Classes

AutoNASPatchManager

A class to handle the monkey patching of the model for automode.

EvolveSearcher

An iterative searcher that uses an evolutionary algorithm to optimize the subnet config.

IterativeSearcher

Base class for iterative search algorithms.

RandomSearcher

An iterative searcher that samples subnets randomly.

Functions

convert_autonas_searchspace

Convert search space for AutoNAS mode with correct patch manager.

convert_searchspace

Convert given model into a search space.

export_searchspace

Export a subnet configuration of the search space to a regular model.

restore_autonas_searchspace

Restore search space for AutoNAS mode with correct patch manager.

restore_export

Restore & export the subnet configuration of the search space to a regular model.

restore_searchspace

Restore a search space from the given model.

update_autonas_metadata

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

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.

Select best model.

Return type:

None

after_step()

Run after each iterative step.

Return type:

None

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 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:
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:
Return type:

Tuple[Module, Dict[str, Any]]

restore_autonas_searchspace(model, config, metadata)

Restore search space for AutoNAS mode with correct patch manager.

Parameters:
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:
Return type:

None