botorch icon indicating copy to clipboard operation
botorch copied to clipboard

Adding H-Entropy Search and a corresponding tutorial

Open sangttruong opened this issue 2 years ago • 13 comments

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: image

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

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.)

sangttruong avatar Apr 16 '23 19:04 sangttruong

Codecov Report

Merging #1794 (c131b0d) into main (b757b20) will decrease coverage by 0.02%. The diff coverage is 96.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

codecov[bot] avatar Apr 16 '23 20:04 codecov[bot]

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-missing as described in CONTRIBUTING.md, or just wait for the Codecov analysis on GitHub.
  • Could you run black . and ufmt format . as described in CONTRIBUTING.md? This will get the linter passing.

esantorella avatar Apr 17 '23 11:04 esantorella

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

facebook-github-bot avatar Jun 24 '23 17:06 facebook-github-bot

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 avatar Jun 27 '23 04:06 Balandat

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

facebook-github-bot avatar Jul 13 '23 15:07 facebook-github-bot

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 avatar Jul 13 '23 16:07 Balandat

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

facebook-github-bot avatar Jul 15 '23 00:07 facebook-github-bot

@esantorella @Ryan-Rhys Do you have any other comments or feedback on this PR?

sangttruong avatar Jul 15 '23 14:07 sangttruong

@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!

esantorella avatar Jul 20 '23 20:07 esantorella

@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.

sangttruong avatar Aug 05 '23 08:08 sangttruong

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

facebook-github-bot avatar Aug 07 '23 16:08 facebook-github-bot

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!

saitcakmak avatar Jan 22 '24 18:01 saitcakmak