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

Bug fix: Make MBM acquisition pass the correct args to each BoTorch optimizer; cleanup #2571

Closed
wants to merge 1 commit into from

Conversation

esantorella
Copy link
Contributor

Summary:
Motivation: MBM can dispatch to four different BoTorch optimizers depending on the search space. Currently, optimize_acqf_discrete_local_search is failing because it is passed the inappropriate argument sequential.

This diff

  • Makes the logic more clear: First, Acquisition.optimize determines which of the four optimizers is appropriate. then it constructs arguments based on that optimizer. Then it constructs arguments for the optimizers using optimizer_argparse. Then it does any optimizer_specific logic and calls the optimizer.
  • Fixes optimizer_argparse so that inappropriate arguments such as sequential are not passed to optimizers they don't apply to.
  • Removes special-casing for qNEHVI and qMES in optimizer_argparse that wasn't actually doing anything
  • Extends unit tests for optimizer_argparse to check all optimizers
  • Reduces the usage and scope of mocks in test_acquisition so that optimize_acqf and its variants are actually run as much as possible.

Differential Revision: D59354709

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

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

@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 99.15254% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.23%. Comparing base (3a06169) to head (8a00600).

Files Patch % Lines
ax/models/torch/botorch_modular/acquisition.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2571   +/-   ##
=======================================
  Coverage   95.22%   95.23%           
=======================================
  Files         489      489           
  Lines       47612    47661   +49     
=======================================
+ Hits        45338    45389   +51     
+ Misses       2274     2272    -2     

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

@facebook-github-bot
Copy link
Contributor

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

esantorella added a commit to esantorella/Ax that referenced this pull request Jul 9, 2024
…ptimizer; cleanup (facebook#2571)

Summary:
Pull Request resolved: facebook#2571

Motivation: MBM can dispatch to four different BoTorch optimizers depending on the search space. Currently, `optimize_acqf_discrete_local_search` is failing because it is passed the inappropriate argument `sequential`.

This diff
* Makes the logic more clear: First, Acquisition.optimize determines which of the four optimizers is appropriate. then it constructs arguments based on that optimizer. Then it constructs arguments for the optimizers using `optimizer_argparse`. Then it does any optimizer_specific logic and calls the optimizer.
* Fixes optimizer_argparse so that inappropriate arguments such as `sequential` are not passed to optimizers they don't apply to.
* Removes special-casing for qNEHVI and qMES in optimizer_argparse that wasn't actually doing anything
* Extends unit tests for `optimizer_argparse` to check all optimizers
* Reduces the usage and scope of mocks in test_acquisition so that `optimize_acqf` and its variants are actually run as much as possible.

Differential Revision: D59354709
esantorella added a commit to esantorella/Ax that referenced this pull request Jul 9, 2024
…ptimizer; cleanup (facebook#2571)

Summary:
Pull Request resolved: facebook#2571

Motivation: MBM can dispatch to four different BoTorch optimizers depending on the search space. Currently, `optimize_acqf_discrete_local_search` is failing because it is passed the inappropriate argument `sequential`.

This diff
* Makes the logic more clear: First, Acquisition.optimize determines which of the four optimizers is appropriate. then it constructs arguments based on that optimizer. Then it constructs arguments for the optimizers using `optimizer_argparse`. Then it does any optimizer_specific logic and calls the optimizer.
* Fixes optimizer_argparse so that inappropriate arguments such as `sequential` are not passed to optimizers they don't apply to.
* Removes special-casing for qNEHVI and qMES in optimizer_argparse that wasn't actually doing anything
* Extends unit tests for `optimizer_argparse` to check all optimizers
* Reduces the usage and scope of mocks in test_acquisition so that `optimize_acqf` and its variants are actually run as much as possible.

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

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

esantorella added a commit to esantorella/Ax that referenced this pull request Jul 9, 2024
…ptimizer; cleanup (facebook#2571)

Summary:
Pull Request resolved: facebook#2571

Motivation: MBM can dispatch to four different BoTorch optimizers depending on the search space. Currently, `optimize_acqf_discrete_local_search` is failing because it is passed the inappropriate argument `sequential`.

This diff
* Makes the logic more clear: First, Acquisition.optimize determines which of the four optimizers is appropriate. then it constructs arguments based on that optimizer. Then it constructs arguments for the optimizers using `optimizer_argparse`. Then it does any optimizer_specific logic and calls the optimizer.
* Fixes optimizer_argparse so that inappropriate arguments such as `sequential` are not passed to optimizers they don't apply to.
* Removes special-casing for qNEHVI and qMES in optimizer_argparse that wasn't actually doing anything
* Extends unit tests for `optimizer_argparse` to check all optimizers
* Reduces the usage and scope of mocks in test_acquisition so that `optimize_acqf` and its variants are actually run as much as possible.

Differential Revision: D59354709
…ptimizer; cleanup (facebook#2571)

Summary:
Pull Request resolved: facebook#2571

# Context
The current flow is
1. MBM `Acquisition.optimize` constructs arguments passed to BoTorch optimizers in `optimizer_argparse` without knowing which of the four optimizers it will be passing the arguments to. It has only a boolean flag indicating whether the optimizer is discrete.
2. `Acquisition.optimize` decides which of the four optimizers to use and does optimizer specific-logic (these two parts are not really sequential).
3. `Acquisition.optimize` calls a BoTorch optimizer, passing some arguments that may not apply to the optimizer that actually got used.
4. Prior to pytorch/botorch#2390, the inappropriate arguments would be silently ignored, but now they raise an exception.

MBM can dispatch to four different BoTorch optimizers depending on the search space. Currently, `optimize_acqf_discrete_local_search` is failing because it is passed the inappropriate argument `sequential`.

# This diff
* Makes the flow within `Acquisition.optimize` more clear and changes `optimizer_argparse` so that inappropriate arguments such as `sequential` are not passed to optimizers they don't apply to:
1. `Acquisition.optimize` determines which of the four optimizers is appropriate.
2. `Acquisition.optimize` constructs arguments based on that optimizer, only constructing needed arguments.
 3. Then it does any optimizer-specific logic.
4. Then it calls a BoTorch optimizer; there is no longer an error because only appropriate arguments were passed.
* Extends unit tests for `optimizer_argparse` to check all optimizers
* Reduces the usage and scope of mocks in test_acquisition so that `optimize_acqf` and its variants are actually run as much as possible.

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

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 1a6faa6.

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.

3 participants