Skip to content

Commit 8bda455

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Fix imports in MBM tutorials (#2732)
Summary: `ax.modelbridge.registry.Models` has been renamed to `Generators`. This diff updates the tutorials to utilize the new name. Pull Request resolved: #2732 Reviewed By: esantorella Differential Revision: D69210338 Pulled By: saitcakmak fbshipit-source-id: d417f3904828b597b801be780c3b29eb5a432bbe
1 parent e8749df commit 8bda455

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

tutorials/custom_acquisition/custom_acquisition.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,20 +580,20 @@
580580
"outputs": [],
581581
"source": [
582582
"from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy\n",
583-
"from ax.modelbridge.registry import Models\n",
583+
"from ax.modelbridge.registry import Generators\n",
584584
"\n",
585585
"\n",
586586
"gs = GenerationStrategy(\n",
587587
" steps=[\n",
588588
" # Quasi-random initialization step\n",
589589
" GenerationStep(\n",
590-
" model=Models.SOBOL,\n",
590+
" model=Generators.SOBOL,\n",
591591
" num_trials=5, # How many trials should be produced from this generation step\n",
592592
" model_kwargs={\"seed\": 999}, # Any kwargs you want passed into the model\n",
593593
" ),\n",
594594
" # Bayesian optimization step using the custom acquisition function\n",
595595
" GenerationStep(\n",
596-
" model=Models.BOTORCH_MODULAR,\n",
596+
" model=Generators.BOTORCH_MODULAR,\n",
597597
" num_trials=-1, # No limitation on how many trials should be produced from this step\n",
598598
" # For `BOTORCH_MODULAR`, we pass in kwargs to specify what surrogate or acquisition function to use.\n",
599599
" # `acquisition_options` specifies the set of additional arguments to pass into the input constructor.\n",

tutorials/custom_botorch_model_in_ax/custom_botorch_model_in_ax.ipynb

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,10 @@
157157
"showInput": false
158158
},
159159
"source": [
160-
"### Instantiate a `BoTorchModel` in Ax\n",
160+
"### Instantiate a `BoTorchGenerator` in Ax\n",
161161
"\n",
162-
"A `BoTorchModel` in Ax encapsulates both the surrogate -- which `Ax` calls a `Surrogate` and BoTorch calls a `Model` -- and an acquisition function. Here, we will only specify the custom surrogate and let Ax choose the default acquisition function.\n",
162+
"A `BoTorchGenerator` in Ax encapsulates both the surrogate -- which `Ax` calls a `Surrogate` and BoTorch calls a `Model` -- and an acquisition function. Here, we will only specify the custom surrogate and let Ax choose the default acquisition function.\n",
163163
"\n",
164-
"Most models should work with the base `Surrogate` in Ax, except for BoTorch `ModelListGP`, which works with `ListSurrogate`.\n",
165164
"Note that the `Model` (e.g., the `SimpleCustomGP`) must implement `construct_inputs`, as this is used to construct the inputs required for instantiating a `Model` instance from the experiment data."
166165
]
167166
},
@@ -188,11 +187,11 @@
188187
},
189188
"outputs": [],
190189
"source": [
191-
"from ax.models.torch.botorch_modular.model import BoTorchModel\n",
190+
"from ax.models.torch.botorch_modular.model import BoTorchGenerator\n",
192191
"from ax.models.torch.botorch_modular.surrogate import Surrogate, SurrogateSpec\n",
193192
"from ax.models.torch.botorch_modular.utils import ModelConfig\n",
194193
"\n",
195-
"ax_model = BoTorchModel(\n",
194+
"ax_model = BoTorchGenerator(\n",
196195
" surrogate=Surrogate(\n",
197196
" surrogate_spec=SurrogateSpec(\n",
198197
" model_configs=[\n",
@@ -230,11 +229,11 @@
230229
"source": [
231230
"### Combine with a `ModelBridge`\n",
232231
"\n",
233-
"`Model`s in Ax require a `ModelBridge` to interface with `Experiment`s. A `ModelBridge` takes the inputs supplied by the `Experiment` and converts them to the inputs expected by the `Model`. For a `BoTorchModel`, we use `TorchModelBridge`. The Modular BoTorch interface creates the `BoTorchModel` and the `TorchModelBridge` in a single step, as follows:\n",
232+
"`Model`s in Ax require a `ModelBridge` to interface with `Experiment`s. A `ModelBridge` takes the inputs supplied by the `Experiment` and converts them to the inputs expected by the `Model`. For a `BoTorchGenerator`, we use `TorchModelBridge`. The Modular BoTorch interface creates the `BoTorchGenerator` and the `TorchModelBridge` in a single step, as follows:\n",
234233
"\n",
235234
"```\n",
236-
"from ax.modelbridge.registry import Models\n",
237-
"model_bridge = Models.BOTORCH_MODULAR(\n",
235+
"from ax.modelbridge.registry import Generators\n",
236+
"model_bridge = Generators.BOTORCH_MODULAR(\n",
238237
" experiment=experiment,\n",
239238
" data=data,\n",
240239
" surrogate=Surrogate(SimpleCustomGP),\n",
@@ -308,19 +307,19 @@
308307
"outputs": [],
309308
"source": [
310309
"from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy\n",
311-
"from ax.modelbridge.registry import Models\n",
310+
"from ax.modelbridge.registry import Generators\n",
312311
"\n",
313312
"\n",
314313
"gs = GenerationStrategy(\n",
315314
" steps=[\n",
316315
" # Quasi-random initialization step\n",
317316
" GenerationStep(\n",
318-
" model=Models.SOBOL,\n",
317+
" model=Generators.SOBOL,\n",
319318
" num_trials=5, # How many trials should be produced from this generation step\n",
320319
" ),\n",
321320
" # Bayesian optimization step using the custom acquisition function\n",
322321
" GenerationStep(\n",
323-
" model=Models.BOTORCH_MODULAR,\n",
322+
" model=Generators.BOTORCH_MODULAR,\n",
324323
" num_trials=-1, # No limitation on how many trials should be produced from this step\n",
325324
" # For `BOTORCH_MODULAR`, we pass in kwargs to specify what surrogate or acquisition function to use.\n",
326325
" model_kwargs={\n",
@@ -1809,10 +1808,10 @@
18091808
},
18101809
"outputs": [],
18111810
"source": [
1812-
"from ax.modelbridge.registry import Models\n",
1811+
"from ax.modelbridge.registry import Generators\n",
18131812
"\n",
18141813
"\n",
1815-
"sobol = Models.SOBOL(exp.search_space)\n",
1814+
"sobol = Generators.SOBOL(exp.search_space)\n",
18161815
"\n",
18171816
"for i in range(5):\n",
18181817
" trial = exp.new_trial(generator_run=sobol.gen(1))\n",
@@ -1878,7 +1877,7 @@
18781877
"source": [
18791878
"with fast_smoke_test():\n",
18801879
" for i in range(NUM_EVALS - 5):\n",
1881-
" model_bridge = Models.BOTORCH_MODULAR(\n",
1880+
" model_bridge = Generators.BOTORCH_MODULAR(\n",
18821881
" experiment=exp,\n",
18831882
" data=exp.fetch_data(),\n",
18841883
" surrogate_spec=SurrogateSpec(\n",

0 commit comments

Comments
 (0)