Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in optimize_objective with fixed features #2691

Closed
wants to merge 1 commit into from

Conversation

esantorella
Copy link
Member

Summary:
Context: As per #2686, bounds for optimize_acqf are not constructed correctly in optimize_objective, which is used in input constructors for qKG-type acquisition functions. This issue wasn't surfaced by unit tests because optimize_acqf was mocked out. In the process of shoring up the test, I discovered a second bug: This optimize_objective doesn't work with constraints, because the optimizer is set to be L-BFGS-B when it isn't otherwise specified, and L-BFGS-B doesn't work with BoTorch-style constraints (only simple box constraints, aka BoTorch bounds).

So I guess the input constructors for qKG-style acquisition functions haven't been working with fixed features or with constraints for a long time -- both usages would just error.

The existing unit test should have caught this but didn't due to use of mocks, so I removed the mocking.

Changes:

In optimize_objective:

  • Use bounds.shape instead of len(bounds) when constructing a list of features for fixed_features_list
  • Don't specify 'method' if the user doesn't pass it, so it can be automatically chosen based on the presence of constraints.

Other:

  • In optimize_acqf, cleaned up some logic. This doesn't have any effect on behavior.
  • Added a type annotation

Differential Revision: D68464825

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 21, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68464825

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.98%. Comparing base (589260b) to head (7b8d92c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2691   +/-   ##
=======================================
  Coverage   99.98%   99.98%           
=======================================
  Files         200      200           
  Lines       18232    18238    +6     
=======================================
+ Hits        18230    18236    +6     
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Summary:

**Context:** As per pytorch#2686, bounds for `optimize_acqf` are not constructed correctly in `optimize_objective`, which is used in input constructors for qKG-type acquisition functions. This issue wasn't surfaced by unit tests because `optimize_acqf` was mocked out. In the process of shoring up the test, I discovered a second bug: This `optimize_objective` doesn't work with constraints, because the optimizer is set to be L-BFGS-B when it isn't otherwise specified, and L-BFGS-B doesn't work with BoTorch-style constraints (only simple box constraints, aka BoTorch bounds).

So I guess the input constructors for qKG-style acquisition functions haven't been working with fixed features or with constraints for a long time -- both usages would just error.

The existing unit test should have caught this but didn't due to use of mocks, so I removed the mocking.

**Changes:**

In `optimize_objective`:
* Use `bounds.shape` instead of `len(bounds)` when constructing a list of features for `fixed_features_list`
* Don't specify 'method' if the user doesn't pass it, so it can be automatically chosen based on the presence of constraints.

Other:
* In `optimize_acqf`, cleaned up some logic. This doesn't have any effect on behavior.
* Added a type annotation

Differential Revision: D68464825
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68464825

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68464825

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 6b75672.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants