Abstract runner
smac.runner.abstract_runner
#
AbstractRunner
#
Bases: ABC
Interface class to handle the execution of SMAC configurations. This interface defines how to interact with the SMBO loop. The complexity of running a configuration as well as handling the results is abstracted to the SMBO via an AbstractRunner.
From SMBO perspective, launching a configuration follows a submit/collect scheme as follows:
-
A run is launched via
submit_run() -
submit_runinternally callsrun_wrapper(), a method that contains common processing functions among different runners. - A class that implements AbstractRunner defines
run()which is really the algorithm to translate aTrialInfoto aTrialValue, i.e. a configuration to an actual result. - A completed run is collected via
iter_results(), which iterates and consumes any finished runs, if any. - This interface also offers the method
wait()as a mechanism to make sure we have enough data in the next iteration to make a decision. For example, the intensifier might not be able to select the next challenger until more results are available.
| PARAMETER | DESCRIPTION |
|---|---|
scenario
|
TYPE:
|
required_arguments
|
A list of required arguments, which are passed to the target function. |
Source code in smac/runner/abstract_runner.py
is_running
abstractmethod
#
is_running() -> bool
Whether there are trials still running.
Generally, if the runner is serial, launching a trial instantly returns its result. On parallel runners, there might be pending configurations to complete.
Source code in smac/runner/abstract_runner.py
iter_results
abstractmethod
#
iter_results() -> Iterator[tuple[TrialInfo, TrialValue]]
This method returns any finished configuration, and returns a list with the
results of executing the configurations. This class keeps populating results
to self._results_queue until a call to get_finished trials is done. In this case,
the self._results_queue list is emptied and all trial values produced by running
run are returned.
| RETURNS | DESCRIPTION |
|---|---|
Iterator[tuple[TrialInfo, TrialValue]]:
|
A list of TrialInfo/TrialValue tuples, all of which have been finished. |
Source code in smac/runner/abstract_runner.py
run
abstractmethod
#
run(
config: Configuration,
instance: str | None = None,
budget: float | None = None,
seed: int | None = None,
additional_info: dict[str, Any] | None = None,
) -> tuple[
StatusType,
float | list[float],
float,
float,
dict[str, Any],
]
Runs the target function with a configuration on a single instance-budget-seed combination (aka trial).
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Configuration to be passed to the target function.
TYPE:
|
instance
|
The Problem instance.
TYPE:
|
budget
|
A positive, real-valued number representing an arbitrary limit to the target function handled by the target function internally.
TYPE:
|
seed
|
Seed for the random number generator.
TYPE:
|
additional_info
|
Further additional trial information.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
status
|
Status of the trial.
TYPE:
|
cost
|
Resulting cost(s) of the trial. |
runtime
|
The time the target function took to run.
TYPE:
|
cpu_time
|
The time the target function took on hardware to run.
TYPE:
|
val_additional_info
|
All further additional trial value information.
TYPE:
|
Source code in smac/runner/abstract_runner.py
run_wrapper
#
run_wrapper(
trial_info: TrialInfo,
**dask_data_to_scatter: dict[str, Any]
) -> tuple[TrialInfo, TrialValue]
Wrapper around run() to execute and check the execution of a given config. This function encapsulates common handling/processing, so that run() implementation is simplified.
| PARAMETER | DESCRIPTION |
|---|---|
trial_info
|
Object that contains enough information to execute a configuration run in isolation.
TYPE:
|
dask_data_to_scatter
|
When a user scatters data from their local process to the distributed network, this data is distributed in a round-robin fashion grouping by number of cores. Roughly speaking, we can keep this data in memory and then we do not have to (de-)serialize the data every time we would like to execute a target function with a big dataset. For example, when your target function has a big dataset shared across all the target function, this argument is very useful. |
| RETURNS | DESCRIPTION |
|---|---|
info
|
An object containing the configuration launched.
TYPE:
|
value
|
Contains information about the status/performance of config.
TYPE:
|
Source code in smac/runner/abstract_runner.py
submit_trial
abstractmethod
#
submit_trial(trial_info: TrialInfo) -> None
This function submits a configuration embedded in a TrialInfo object, and uses one of the workers to produce
a result (such result will eventually be available on the self._results_queue FIFO).
This interface method will be called by SMBO, with the expectation that a function will be executed by a worker.
What will be executed is dictated by trial_info, and how it will be executed is decided via the child
class that implements a run method.
Because config submission can be a serial/parallel endeavor, it is expected to be implemented by a child class.
| PARAMETER | DESCRIPTION |
|---|---|
trial_info
|
An object containing the configuration launched.
TYPE:
|
Source code in smac/runner/abstract_runner.py
wait
abstractmethod
#
The SMBO/intensifier might need to wait for trials to finish before making a decision.