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

Add TopK downselection for initial batch generation. #2636

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

CompRhys
Copy link
Contributor

@CompRhys CompRhys commented Nov 20, 2024

Motivation

In order to get facebook/Ax#2938 over the line with initial candidate generation that obey the constraints we want to use the existing tooling within botorch. The hard coded logic currently in Ax uses topk to downselect the sobol samples. To make a change there that will not impact existing users we then need to implement topk downselection in botorch.

Test Plan

TODO:

  • add tests for initialize_q_batch_topk

Related PRs

facebook/Ax#2938. (#2610 was initially intended to play part of this solution but then I realized that the pattern I wanted to use was conflating repeats and the batch dimension.)

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

@Balandat Balandat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of small nits, o/w this looks great.

botorch/optim/initializers.py Outdated Show resolved Hide resolved
botorch/optim/initializers.py Show resolved Hide resolved
botorch/optim/initializers.py Outdated Show resolved Hide resolved
botorch/utils/sampling.py Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@Balandat has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@saitcakmak
Copy link
Contributor

Other initializers use Boltzmann sampling through initialize_q_batch helper to achieve a more diverse set of ICs. The motivation is that this will hopefully lead to different local-optima, making it more likely to discover the global optimum. If you have multiple raw samples that are close by, TopK can get you ICs that all lead to the same local optima. Should we follow the same logic in initialize_q_batch instead?

@Balandat
Copy link
Contributor

That would make sense, I'd be interested in seeing a benchmark how that affects performance of SEBO

@CompRhys
Copy link
Contributor Author

I would be entirely happy to not merge this if it will end up as dead code if theres a decision to swap the ic default for SEBO to use Boltzmann sampling. The motivation here was that I want to use the polytope sampling from botorch such that I can add inequality constraints to SEBO, adding a bunch of switching logic is bad in terms of maintenance there so the minimal change to keep the same behavior for how it's currently setup is to add this here.

The longer term idea for the cleanest way to do it I had was based on this #2610 where SEBO default could just pass the X_pareto points as initial batch conditions and then have botorch just fill up the rest of the requested n_restarts without needing to call anything in Ax from botorch to do the initial sampling that currently uses topk to get 1/2 of the initial conditions.

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.

Project coverage is 99.97%. Comparing base (3f2e2c7) to head (8e27422).

Files with missing lines Patch % Lines
botorch/optim/initializers.py 88.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2636      +/-   ##
==========================================
- Coverage   99.98%   99.97%   -0.02%     
==========================================
  Files         196      196              
  Lines       17365    17382      +17     
==========================================
+ Hits        17363    17377      +14     
- Misses          2        5       +3     

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

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants