syne_tune.backend.simulator_backend.simulator_callback module

class syne_tune.backend.simulator_backend.simulator_callback.SimulatorCallback(extra_results_composer=None)[source]

Bases: StoreResultsCallback

Callback to be used in run() in order to support the SimulatorBackend.

This is doing two things. First, on_tuning_sleep() is advancing the time_keeper of the simulator backend by tuner_sleep_time (also defined in the backend). The real sleep time in Tuner must be 0.

Second, we need to make sure that results written out are annotated by simulated time, not real time. This is already catered for by SimulatorBackend adding ST_TUNER_TIME entries to each result it receives.

Third (and most subtle), we need to make sure the stop criterion in run() is using simulated time instead of real time when making a decision based on max_wallclock_time. By default, StoppingCriterion takes TuningStatus as an input, which counts real time and knows nothing about simulated time. To this end, we modify stop_criterion of the tuner to instead depend on the ST_TUNER_TIME fields in the results received. This allows us to keep both Tuner and TuningStatus independent of the time keeper.

Parameters:

extra_results_composer (Optional[ExtraResultsComposer]) – Optional. If given, this is called in on_trial_result(), and the resulting dictionary is appended as extra columns to the results dataframe

on_tuning_start(tuner)[source]

Called at start of tuning loop

Parameters:

tuner (Tuner) – Tuner object

on_tuning_sleep(sleep_time)[source]

Called just after tuner has slept, because no worker was available

Parameters:

sleep_time (float) – Time (in secs) for which tuner has just slept

on_tuning_end()[source]

Called once the tuning loop terminates

This is called before Tuner object is serialized (optionally), and also before running jobs are stopped.