Skip to content

Commit a9c5eff

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Remove current_x validation from mixed optimizer (#2678)
Summary: ## Motivation Removes the validation that `current_x` is within bounds from the `continuous_step` of the mixed optimizer. In some cases (e.g., with `Log` transform in Ax), the `post_processing_func` can bring the `current_x` slightly outside of the bounds, which leads to the optimization erroring out. The optimizer is capable of handling these outside of bounds starting points, so the validation doesn't provide much benefit. Pull Request resolved: #2678 Test Plan: Removed the test checking for the validation. Reviewed By: esantorella Differential Revision: D68276788 Pulled By: saitcakmak fbshipit-source-id: caf82a867eb448b9fa19a083f0c5a29acdfd8f6f
1 parent ff040d0 commit a9c5eff

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

botorch/optim/optimize_mixed.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,7 @@ def continuous_step(
524524
A tuple of two tensors: a (1 x d)-dim tensor of optimized points
525525
and a (1)-dim tensor of acquisition values.
526526
"""
527-
bounds = opt_inputs.bounds
528527
options = opt_inputs.options or {}
529-
if (current_x < bounds[0]).any() or (current_x > bounds[1]).any():
530-
raise ValueError("continuous_step requires current_x to be within bounds.")
531528
if len(discrete_dims) == len(current_x): # nothing continuous to optimize
532529
with torch.no_grad():
533530
return current_x, opt_inputs.acq_function(current_x.unsqueeze(0))

test/optim/test_optimize_mixed.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,6 @@ def test_continuous_step(self):
420420
self.assertTrue(X is X_out) # testing pointer equality for due to short cut
421421
self.assertAllClose(ei_val, ei(X[None]))
422422

423-
# Input outside of bounds raises error.
424-
invalid_X = X.clone()
425-
invalid_X[2] = 2
426-
with self.assertRaisesRegex(
427-
ValueError,
428-
"continuous_step requires current_x to be",
429-
):
430-
X_new, ei_val = continuous_step(
431-
opt_inputs=_make_opt_inputs(
432-
acq_function=ei,
433-
bounds=bounds,
434-
options={"maxiter_continuous": 32},
435-
),
436-
discrete_dims=binary_dims,
437-
current_x=invalid_X,
438-
)
439-
440423
def test_optimize_acqf_mixed_binary_only(self) -> None:
441424
train_X, train_Y, binary_dims, cont_dims = self._get_data()
442425
dim = len(binary_dims) + len(cont_dims)

0 commit comments

Comments
 (0)