Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing num_init_trials in MBM benchmark method #2286

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ax/benchmark/methods/modular_botorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy
from ax.modelbridge.registry import Models
from ax.models.torch.botorch_modular.model import SurrogateSpec

from ax.service.scheduler import SchedulerOptions
from botorch.acquisition.acquisition import AcquisitionFunction
from botorch.acquisition.analytic import LogExpectedImprovement
Expand Down Expand Up @@ -59,13 +58,15 @@ def get_sobol_botorch_modular_acquisition(
acqf_name = acqf_name_abbreviations.get(
acquisition_cls.__name__, acquisition_cls.__name__
)
name = f"MBM::{model_name}_{acqf_name}"
name = name or f"MBM::{model_name}_{acqf_name}"

generation_strategy = GenerationStrategy(
name=name,
steps=[
GenerationStep(
model=Models.SOBOL, num_trials=num_sobol_trials, min_trials_observed=5
model=Models.SOBOL,
num_trials=num_sobol_trials,
min_trials_observed=num_sobol_trials,
),
GenerationStep(
model=Models.BOTORCH_MODULAR,
Expand Down
4 changes: 4 additions & 0 deletions ax/benchmark/tests/methods/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def test_benchmark_replication_runs(self) -> None:
model_cls=SingleTaskGP,
scheduler_options=get_sequential_optimization_scheduler_options(),
acquisition_cls=LogExpectedImprovement,
num_sobol_trials=2,
name="test",
distribute_replications=False,
)
n_sobol_trials = method.generation_strategy._steps[0].num_trials
self.assertEqual(n_sobol_trials, 2)
self.assertEqual(method.name, "test")
# Only run one non-Sobol trial
problem = get_problem(problem_name="ackley4", num_trials=n_sobol_trials + 1)
result = benchmark_replication(problem=problem, method=method, seed=0)
Expand Down
Loading