Skip to content

Commit 9a296b6

Browse files
Balandatmeta-codesync[bot]
authored andcommitted
Speed up slow tutorial smoke tests (meta-pytorch#3238)
Summary: Pull Request resolved: meta-pytorch#3238 Improve SMOKE_TEST handling in 8 botorch tutorial notebooks that were taking >200s in CI. The changes fall into two categories: 1. Added SMOKE_TEST handling where none existed: - orthogonal_additive_gp: Added SMOKE_TEST env var check, reduced n_train (20→10), n_test (500→50), n_2nd (50→20) - max_value_entropy: Added SMOKE_TEST check, reduced num_restarts (10→2), raw_samples (512→4), candidate_set (1000→100) 2. Improved existing SMOKE_TEST handling with missed parameters: - cost_aware_bayesian_optimization: Reduced budget (25→5) which was never gated on SMOKE_TEST - multi_fidelity_bo: Reduced batch q (4→2) in both MFKG and EI loops - multi_objective_bo: Reduced BATCH_SIZE (4→2), affects all 3 acquisition functions per iteration - saasbo: Reduced final 'predict on test points' section from 50→10 train/test points - closed_loop_botorch_only: Reduced N_TRIALS (3→1 in smoke mode) - decoupled_mobo: Reduced COST_BUDGET (54→30) Measured speedups (test session 13510799038369321): - orthogonal_additive_gp: 261.8s → 163.6s (1.6x) - max_value_entropy: 220.2s → 104.6s (2.1x) - cost_aware_bayesian_optimization: 234.9s → 143.6s (1.6x) - multi_fidelity_bo: 247.6s → 147.3s (1.7x) - multi_objective_bo: 232.9s → 134.4s (1.7x) - saasbo: 231.0s → 126.6s (1.8x) - closed_loop_botorch_only: 208.8s → 109.7s (1.9x) - decoupled_mobo: 256.6s → 162.0s (1.6x) Overall test suite: 580s → 185s (3.1x speedup). All 64 tests pass. Reviewed By: esantorella Differential Revision: D97134436 fbshipit-source-id: cfd6b3f5c295c9dafcb61e3a945e070a536aa0ba
1 parent 4decc06 commit 9a296b6

8 files changed

Lines changed: 8414 additions & 8381 deletions

File tree

tutorials/closed_loop_botorch_only/closed_loop_botorch_only.ipynb

Lines changed: 1189 additions & 1189 deletions
Large diffs are not rendered by default.

tutorials/cost_aware_bayesian_optimization/cost_aware_bayesian_optimization.ipynb

Lines changed: 1012 additions & 1009 deletions
Large diffs are not rendered by default.

tutorials/decoupled_mobo/decoupled_mobo.ipynb

Lines changed: 1553 additions & 1547 deletions
Large diffs are not rendered by default.

tutorials/max_value_entropy/max_value_entropy.ipynb

Lines changed: 529 additions & 520 deletions
Large diffs are not rendered by default.

tutorials/multi_fidelity_bo/multi_fidelity_bo.ipynb

Lines changed: 1066 additions & 1062 deletions
Large diffs are not rendered by default.

tutorials/multi_objective_bo/multi_objective_bo.ipynb

Lines changed: 1860 additions & 1857 deletions
Large diffs are not rendered by default.

tutorials/orthogonal_additive_gp/orthogonal_additive_gp.ipynb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"outputs": [],
3030
"source": [
3131
"# Install dependencies if we are running in colab\n",
32+
"import os\n",
3233
"import sys\n",
3334
"if 'google.colab' in sys.modules:\n",
3435
" %pip install botorch\n",
@@ -48,6 +49,8 @@
4849
"torch.manual_seed(0)\n",
4950
"torch.set_default_dtype(torch.float64)\n",
5051
"\n",
52+
"SMOKE_TEST = os.environ.get(\"SMOKE_TEST\")\n",
53+
"\n",
5154
"%matplotlib inline"
5255
]
5356
},
@@ -98,7 +101,7 @@
98101
" )\n",
99102
"\n",
100103
"# Generate sparse training data in [0, 1]^5\n",
101-
"n_train = 20\n",
104+
"n_train = 10 if SMOKE_TEST else 20\n",
102105
"train_X = torch.rand(n_train, d)\n",
103106
"train_Y = (test_function(train_X) + NOISE_STD * torch.randn(n_train)).unsqueeze(-1)\n",
104107
"\n",
@@ -155,7 +158,7 @@
155158
"\n",
156159
"# Evaluate both on a dense test set\n",
157160
"torch.manual_seed(42)\n",
158-
"n_test = 500\n",
161+
"n_test = 50 if SMOKE_TEST else 500\n",
159162
"test_X = torch.rand(n_test, d)\n",
160163
"test_Y = test_function(test_X)\n",
161164
"\n",
@@ -419,7 +422,7 @@
419422
"\n",
420423
"# Generate new training data with the interaction term\n",
421424
"torch.manual_seed(1)\n",
422-
"n_2nd = 50\n",
425+
"n_2nd = 20 if SMOKE_TEST else 50\n",
423426
"train_X_2nd = torch.rand(n_2nd, d)\n",
424427
"train_Y_2nd = (\n",
425428
" test_function_with_interaction(train_X_2nd) + NOISE_STD * torch.randn(n_2nd)\n",
@@ -443,7 +446,8 @@
443446
"\n",
444447
"# Compare RMSE on test set\n",
445448
"torch.manual_seed(42)\n",
446-
"test_X_2nd = torch.rand(500, d)\n",
449+
"n_test_2nd = 50 if SMOKE_TEST else 500\n",
450+
"test_X_2nd = torch.rand(n_test_2nd, d)\n",
447451
"test_Y_2nd = test_function_with_interaction(test_X_2nd)\n",
448452
"\n",
449453
"with torch.no_grad():\n",

0 commit comments

Comments
 (0)