Developer: How to extend search#
This tutorial shows how to extend the search space and search strategy in MASE.
How does MASE search work?#
search_space defines the search space using two dictionaries:
search_space.choices_flattened: a flatten dictionary of all the choices in the search spacesearch_space.choice_lengths_flattened: a flatten dictionary of the lengths of all the choices in the search space
For every trial,
search_strategy samples from search_space. search_strategy uses
search_space.choice_lengths_flattenedto createsampled_indexesfor each value insearch_space.choices_flattened. Then search_strategy usessearch_space.flattened_indexes_to_config(...)to convertsampled_indexesto asampled_config.search_strategy passes the
sampled_configtosearch_space.rebuild_model(...)to create a newmodel.search_strategy passes to
modeltosearch_strategy.sw_runner/search_strategy.hw_runnerto get the sw/hw metrics.search_strategy will use the sw/hw metrics to guide next trial.
In the end, search_strategy will save the researched results.
Note that search_space is search space + model, and search_strategy is search algorithm + dataloader. search_strategy interacts with search_space through sampled_config, rebuilt model, and sw_runner/hw_runner.
How to extend search_space?#
[Required]Create a new search space class that inherits fromSearchSpaceBaseatmase-tools/machop/chop/actions/search/search_space/base.pyand implement corresponding abstract methods.[Required]Register the new search space toSEARCH_SPACE_MAPatmase-tools/machop/chop/actions/search/search_space/__init__.py.[Optional]Add new software (hardware) metrics:subclass
SoftwareRunnerBaseatmase-tools/machop/chop/actions/search/runners/software/base.pyand implement corresponding abstract methods.Register the new software metrics at
SOFTWARE_RUNNER_MAPatmase-tools/machop/chop/actions/search/runners/software/__init__.py.
🚧 under construction 🚧