From 62d7efb484e81815f365bca650e97b22ca546f34 Mon Sep 17 00:00:00 2001 From: Sergiy Matusevych Date: Wed, 3 Jul 2024 14:14:44 -0700 Subject: [PATCH] Make sure One Shot Optimizer always returns the same suggestion (#759) Make sure the `OneShotOptimizer.suggest()` call always returns the same configuration. Changes related to `MockEnv` determinism moved to #769 Closes #755 --------- Co-authored-by: Brian Kroth --- mlos_bench/mlos_bench/optimizers/one_shot_optimizer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mlos_bench/mlos_bench/optimizers/one_shot_optimizer.py b/mlos_bench/mlos_bench/optimizers/one_shot_optimizer.py index 088ed03bdf..314d048298 100644 --- a/mlos_bench/mlos_bench/optimizers/one_shot_optimizer.py +++ b/mlos_bench/mlos_bench/optimizers/one_shot_optimizer.py @@ -18,7 +18,7 @@ _LOG = logging.getLogger(__name__) class OneShotOptimizer(MockOptimizer): """ - Mock optimizer that proposes a single configuration and returns. + No-op optimizer that proposes a single configuration and returns. Explicit configs (partial or full) are possible using configuration files. """ @@ -33,6 +33,14 @@ class OneShotOptimizer(MockOptimizer): _LOG.info("Run a single iteration for: %s", self._tunables) self._max_iter = 1 # Always run for just one iteration. + def suggest(self) -> TunableGroups: + """ + Always produce the same (initial) suggestion. + """ + tunables = super().suggest() + self._start_with_defaults = True + return tunables + @property def supports_preload(self) -> bool: return False