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 <bpkroth@users.noreply.github.com>
This commit is contained in:
Sergiy Matusevych 2024-07-03 14:14:44 -07:00 коммит произвёл GitHub
Родитель cef476c4c4
Коммит 62d7efb484
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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