Skip to content

Commit

Permalink
Make distribute_replications a required input argument (facebook#2051)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#2051

See title

Reviewed By: saitcakmak, Balandat

Differential Revision: D51431736

fbshipit-source-id: d6e2ee402d6b671d774afe89ff4c6e9b3e305d44
  • Loading branch information
David Eriksson authored and facebook-github-bot committed Dec 6, 2023
1 parent f76f721 commit 8481e87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ax/benchmark/methods/modular_botorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
def get_sobol_botorch_modular_acquisition(
model_cls: Type[Model],
acquisition_cls: Type[AcquisitionFunction],
distribute_replications: bool,
scheduler_options: Optional[SchedulerOptions] = None,
distribute_replications: bool = False,
name: Optional[str] = None,
) -> BenchmarkMethod:
model_kwargs: Dict[
Expand Down
12 changes: 10 additions & 2 deletions ax/benchmark/tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def test_replication_mbm(self) -> None:
model_cls=SingleTaskGP,
acquisition_cls=qLogNoisyExpectedImprovement,
scheduler_options=get_sequential_optimization_scheduler_options(),
distribute_replications=False,
),
get_single_objective_benchmark_problem(infer_noise=False, num_trials=6),
"MBM::SingleTaskGP_qLogNEI",
Expand All @@ -155,6 +156,7 @@ def test_replication_mbm(self) -> None:
get_sobol_botorch_modular_acquisition(
model_cls=FixedNoiseGP,
acquisition_cls=qLogNoisyExpectedImprovement,
distribute_replications=False,
),
get_single_objective_benchmark_problem(infer_noise=False, num_trials=6),
"MBM::FixedNoiseGP_qLogNEI",
Expand All @@ -163,6 +165,7 @@ def test_replication_mbm(self) -> None:
get_sobol_botorch_modular_acquisition(
model_cls=FixedNoiseGP,
acquisition_cls=qNoisyExpectedHypervolumeImprovement,
distribute_replications=False,
),
get_multi_objective_benchmark_problem(infer_noise=False, num_trials=6),
"MBM::FixedNoiseGP_qNEHVI",
Expand All @@ -171,6 +174,7 @@ def test_replication_mbm(self) -> None:
get_sobol_botorch_modular_acquisition(
model_cls=SaasFullyBayesianSingleTaskGP,
acquisition_cls=qLogNoisyExpectedImprovement,
distribute_replications=False,
),
get_multi_objective_benchmark_problem(num_trials=6),
"MBM::SAAS_qLogNEI",
Expand Down Expand Up @@ -231,7 +235,9 @@ def test_benchmark_multiple_problems_methods(self) -> None:
methods=[
get_sobol_benchmark_method(),
get_sobol_botorch_modular_acquisition(
model_cls=SingleTaskGP, acquisition_cls=qLogNoisyExpectedImprovement
model_cls=SingleTaskGP,
acquisition_cls=qLogNoisyExpectedImprovement,
distribute_replications=False,
),
],
seeds=(0, 1),
Expand All @@ -250,7 +256,9 @@ def test_timeout(self) -> None:
)

generation_strategy = get_sobol_botorch_modular_acquisition(
model_cls=SingleTaskGP, acquisition_cls=qLogNoisyExpectedImprovement
model_cls=SingleTaskGP,
acquisition_cls=qLogNoisyExpectedImprovement,
distribute_replications=False,
).generation_strategy

method = BenchmarkMethod(
Expand Down
2 changes: 2 additions & 0 deletions ax/benchmark/tests/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_mbm_acquisition(self) -> None:
model_cls=SingleTaskGP,
acquisition_cls=qKnowledgeGradient,
scheduler_options=get_sequential_optimization_scheduler_options(),
distribute_replications=False,
)
self.assertEqual(method.name, "MBM::SingleTaskGP_qKnowledgeGradient")
gs = method.generation_strategy
Expand All @@ -44,6 +45,7 @@ def test_benchmark_replication_runs(self) -> None:
model_cls=SingleTaskGP,
scheduler_options=get_sequential_optimization_scheduler_options(),
acquisition_cls=LogExpectedImprovement,
distribute_replications=False,
)
n_sobol_trials = method.generation_strategy._steps[0].num_trials
# Only run one non-Sobol trial
Expand Down

0 comments on commit 8481e87

Please sign in to comment.