botorch
botorch copied to clipboard
Adding H-Entropy Search and a corresponding tutorial
Motivation
This pull request introduces an implementation of the H-Entropy Search [1] procedure, along with a tutorial covering two tasks: Top-K Search and MinMax Search. This PR addresses issue #1733, which requested a new acquisition function for top-K search. [1] W. Neiswanger, L. Yu, S. Zhao, C. Meng, S. Ermon. Generalizing Bayesian Optimization with Decision-theoretic Entropies. In Proceedings of the 36th Conference on Neural Information Processing Systems (NeurIPS 2022).
Have you read the Contributing Guidelines on pull requests?
Yes, I have read the Contributing Guidelines on pull requests.
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
In the associated tutorial, two tests can be executed using the built-in 2D Ackley function with an input range of [-1, 1]. Within this range, there are four maxima located at each corner and one minimum at the center. The H-Entropy Search (HES) procedure, employing a Top-K (K = 2) loss function, is expected to identify two of the four maxima, with any combination being acceptable. Meanwhile, the H-Entropy Search procedure utilizing the MinMax loss function should locate one maximum and the central minimum.
Below are the results after running 10 steps of HES with MinMax:

And here are the results after running 10 steps of HES with TopK:

Both images can be reproduced by following the respective tutorial.
Related PRs
Not applicable.
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/pytorch/botorch, and link to your PR here.)
Codecov Report
Merging #1794 (c131b0d) into main (b757b20) will decrease coverage by
0.02%. The diff coverage is96.00%.
:exclamation: Current head c131b0d differs from pull request most recent head 5921865. Consider uploading reports for the commit 5921865 to get more accurate results
@@ Coverage Diff @@
## main #1794 +/- ##
===========================================
- Coverage 100.00% 99.98% -0.02%
===========================================
Files 178 179 +1
Lines 15748 15823 +75
===========================================
+ Hits 15748 15820 +72
- Misses 0 3 +3
| Files Changed | Coverage Δ | |
|---|---|---|
| botorch/acquisition/hentropy_search.py | 96.00% <96.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Thanks a lot for the PR! A couple things:
- BoTorch requires 100% test coverage. Could you add unit tests for the H-entropy search functionality? To check test coverage, you can run
pytest -ra --cov=. --cov-report term-missingas described in CONTRIBUTING.md, or just wait for the Codecov analysis on GitHub. - Could you run
black .andufmt format .as described in CONTRIBUTING.md? This will get the linter passing.
@Balandat has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
Sorry this docs failure isn't exactly actionable - you'll have to add an entry to this json file to link it on the website: https://github.com/pytorch/botorch/blob/main/website/tutorials.json
Speaking of the tutorial - can you push a version that has the outputs included as well? Could you please also make the saving the results (plots) to disk optional and not do that by default?
@Balandat has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
Thanks for tying up all the loose ends. One more outstanding issue: The tutorial is pretty heavyweight, so it'll cause some issues for the CI. We usually use a SMOKE_TEST variable in the notebook to select parameters to make it much cheaper tu run (e.g. number of iterations, data size, number of mc samples, etc). See e.g. how this is used in https://github.com/pytorch/botorch/blob/main/tutorials/closed_loop_botorch_only.ipynb. Could you please add this to the notebook to make sure that it runs quickly? It doesn't have to produce interesting outputs, this is mostly to test in an automated fashion that it's still functional and didn't break due to other code changes. Thanks!
@Balandat has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@esantorella @Ryan-Rhys Do you have any other comments or feedback on this PR?
@esantorella @Ryan-Rhys Do you have any other comments or feedback on this PR?
Sorry for the slow response! It looks like this is still missing unit tests; in particular for acquisition/hentropy_search.py. See my comment above on this, and see here for how other acquisition functions have been tested. Thanks for your patience!
@Ryan-Rhys Ry @esantorella Thank you so much for the feedback. I added a unit test file and adjust the main class according to your comments above. Please let me know if there is any further adjustment I should make.
@esantorella has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
Hi @sangttruong. Looks like this PR went stale but hopefully you're doing well and still interested in landing the contribution! We're trying out a new support model for community contributions: https://github.com/pytorch/botorch/blob/main/CONTRIBUTING.md#community-contributions-beta. Can you move the new additions to the botorch_community, notebooks_community & test_community directories and add the contributor info and other metadata to the files as outlined in the readme files? Thanks!