Commit de1eb9b
Summary:
Fixes #3332.
When both `fixed_features` and `nonlinear_inequality_constraints` are passed to `optimize_acqf` / `gen_candidates_scipy`, the fixed features were being applied to the nonlinear constraints **twice**, scrambling the constraint's input and causing spurious SLSQP failures and "infeasible candidate" errors.
## Root cause
In `gen_candidates_scipy`, the nonlinear constraints go through two independent fixed-feature transforms:
1. `_remove_fixed_features_from_optimization` → `_generate_unfixed_nonlin_constraints` wraps each constraint so it accepts the **reduced** (unfixed) variable and re-inserts the fixed features internally (via `cat` + a `selector` permutation).
2. The wrapper passed to `make_scipy_nonlinear_inequality_constraints` was `f_np_wrapper_`, which carries `fixed_features=fixed_features_` and **also** re-inserts the fixed feature (via `fix_features`) before evaluating the constraint.
So the fixed value gets inserted twice. For `d=5`, `fixed_features={0: 1.0}` (`selector=[4,0,1,2,3]`), the reduced `[x1,x2,x3,x4]` first becomes `[1.0,x1,x2,x3,x4]` (from `fix_features`), then the constraint wrapper appends `1.0` and applies `selector`, yielding `[x4, 1.0, x1, x2, x3]` — exactly the scramble reported in #3332.
The acquisition objective wrapper (`f_np_wrapper_`) is correct as-is, since the acquisition function genuinely lives in the full space; only the already-transformed constraints were over-corrected.
## Fix
Use a separate wrapper with `fixed_features=None` for the already-transformed nonlinear constraints, as suggested in the issue.
## Testing
- The existing fixed-features + nonlinear test (`test_optimize_acqf_nonlinear_constraints`) used a permutation-invariant constraint (`4 - x.sum()`) with a `torch.sort()` assertion, so it could not detect coordinate scrambling.
- Added `test_optimize_acqf_nonlinear_constraints_with_fixed_features` with a **coordinate-sensitive** constraint and an order-sensitive assertion. Mutation-checked: it fails on the unpatched code and passes with the fix.
- `test_optimize.py`, `test_gen.py`, `test_parameter_constraints.py`, `test_utils.py` all pass.
Pull Request resolved: #3333
Reviewed By: jandylin
Differential Revision: D109710542
Pulled By: saitcakmak
fbshipit-source-id: bf60b07cfe81b033ab04fd8afb913475f16bf0fe
1 parent ade1785 commit de1eb9b
2 files changed
Lines changed: 68 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
361 | 371 | | |
362 | 372 | | |
363 | | - | |
| 373 | + | |
364 | 374 | | |
365 | 375 | | |
366 | 376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
97 | 108 | | |
98 | 109 | | |
99 | 110 | | |
| |||
1337 | 1348 | | |
1338 | 1349 | | |
1339 | 1350 | | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1340 | 1397 | | |
1341 | 1398 | | |
1342 | 1399 | | |
| |||
0 commit comments