Skip to content

Commit

Permalink
Remove current_x validation from mixed optimizer (#2678)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Jan 17, 2025
1 parent ff040d0 commit a9c5eff
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
3 changes: 0 additions & 3 deletions botorch/optim/optimize_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,7 @@ def continuous_step(
A tuple of two tensors: a (1 x d)-dim tensor of optimized points
and a (1)-dim tensor of acquisition values.
"""
bounds = opt_inputs.bounds
options = opt_inputs.options or {}
if (current_x < bounds[0]).any() or (current_x > bounds[1]).any():
raise ValueError("continuous_step requires current_x to be within bounds.")
if len(discrete_dims) == len(current_x): # nothing continuous to optimize
with torch.no_grad():
return current_x, opt_inputs.acq_function(current_x.unsqueeze(0))
Expand Down
17 changes: 0 additions & 17 deletions test/optim/test_optimize_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,23 +420,6 @@ def test_continuous_step(self):
self.assertTrue(X is X_out) # testing pointer equality for due to short cut
self.assertAllClose(ei_val, ei(X[None]))

# Input outside of bounds raises error.
invalid_X = X.clone()
invalid_X[2] = 2
with self.assertRaisesRegex(
ValueError,
"continuous_step requires current_x to be",
):
X_new, ei_val = continuous_step(
opt_inputs=_make_opt_inputs(
acq_function=ei,
bounds=bounds,
options={"maxiter_continuous": 32},
),
discrete_dims=binary_dims,
current_x=invalid_X,
)

def test_optimize_acqf_mixed_binary_only(self) -> None:
train_X, train_Y, binary_dims, cont_dims = self._get_data()
dim = len(binary_dims) + len(cont_dims)
Expand Down

0 comments on commit a9c5eff

Please sign in to comment.