Skip to content

Commit

Permalink
check if config in rh when storing state (#997)
Browse files Browse the repository at this point in the history
* check if config in rh when storing state

* maint

* remove unnecessary changes

* Adapt developer install instructions to include pre-commit installation (#994)

* Pipe dask_client through facade for exec on hpc (#983)

* Pipe dask_client through facade for exec on hpc

* Handle pynisher's memory arg

Before: Could only pass int via SMAC with the default unit B, but now tuple/list is possible

* Update CHANGELOG.md

* Make format

* No printi

---------

Co-authored-by: Carolin Benjamins <[email protected]>

* update changelog

* Increase tolerance for runhistory restoration test

---------

Co-authored-by: Sarah Segel <[email protected]>
Co-authored-by: C. Benjamins <[email protected]>
Co-authored-by: Carolin Benjamins <[email protected]>
Co-authored-by: Helena Graf <[email protected]>
  • Loading branch information
5 people authored May 16, 2023
1 parent dcf77ad commit b5c16a1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Improvements
- Callbacks registration is now a public method of the optimizer and allows callbacks to be inserted at a specific position.
- Adapt developer install instructions to include pre-commit installation
- Add option to pass a dask client to the facade, e.g. enables running on a hpc cluster (#983).
- Added scenario.use_default_config argument/attribute=False, that adds the user's configspace default configuration
as an additional_config to the inital design if set to True. This adds one additional configuration to the number of configs
originating from the initial design. Since n_trials is still respected, this results in one fewer BO steps
Expand All @@ -10,13 +12,13 @@
- Add example for using a callback to log run metadata to a file (#996).
- Move base callback and metadata callback files to own callback directory.



## Bugfixes
- The ISB-pair differences over the incumbent's configurations are computed correctly now (#956).
- Adjust amount of configurations in different stages of hyperband brackets to conform to the original paper.
- Fix validation in smbo to use the seed in the scenario.
- Change order of callbacks, intensifier callback for incumbent selection is now the first callback.
- intensifier.get_state() will now check if the configurations contained in the queue is stored in the runhistory (#997)



# 2.0.0
Expand Down
6 changes: 5 additions & 1 deletion smac/intensifier/intensifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def uses_instances(self) -> bool: # noqa: D102

def get_state(self) -> dict[str, Any]: # noqa: D102
return {
"queue": [(self.runhistory.get_config_id(config), n) for config, n in self._queue],
"queue": [
(self.runhistory.get_config_id(config), n)
for config, n in self._queue
if self.runhistory.has_config(config)
],
}

def set_state(self, state: dict[str, Any]) -> None: # noqa: D102
Expand Down
4 changes: 4 additions & 0 deletions smac/runhistory/runhistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ def get_config_id(self, config: Configuration) -> int:
"""Returns the configuration id from a configuration."""
return self._config_ids[config]

def has_config(self, config: Configuration) -> bool:
"""Check if the config is stored in the runhistory"""
return config in self._config_ids

def get_configs(self, sort_by: str | None = None) -> list[Configuration]:
"""Return all configurations in this RunHistory object.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_continue.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def on_tell_end(self, smbo, info: TrialInfo, value: TrialValue) -> bool | None:

# Let's see if we restored the runhistory correctly; used walltime should be roughly the same
# However, since some more things happen in the background, it might be slightly different
assert pytest.approx(smac2._optimizer.used_walltime, 0.2) == smac._optimizer.used_walltime
assert pytest.approx(smac2._optimizer.used_walltime, 0.5) == smac._optimizer.used_walltime
assert smac2.runhistory.finished == smac.runhistory.finished

smac2.optimize()
Expand Down

0 comments on commit b5c16a1

Please sign in to comment.