Skip to content

Conversation

@hvarfner
Copy link
Contributor

A series of improvements directed towards improving the performance of PES & JES, as well as their MultiObj counterparts.

Motivation

As pointed out by @SebastianAment in this paper, the BoTorch variant of JES, and to an extent PES, is brutally slow an suspiciously ill-performing. To bring them up to their potential, I've added a series of performance improvements:

1. Improvement to get_optimal_samples and optimal_posterior_samples: As this is an integral part of their efficiency, I've added suggestions (similar to sample_around_best) to optimize_posterior_samples.
Marginal runtime improvement in acquisition optimization (sampling time practically unchanged):
runtime_pr1
Substantial performance improvement: pr1_regret.

2. Added initializer to acquisition funcction optimization: Similar to KG, ES methods have sensible suggestions for acquisition function optimization in the form of the sampled optima. This drastically reduces the time of acquisition function optimization, which could on occasion take 30+ seconds when num_restarts was large >4.

Benchmarking INC

2b. Multi-objective support for initializer: By re-naming arguments of the multi-objective variants, we get consistency and support for MO variants.

3. Enabled gradient-based optimization for PES: The current implementation contains a while-loop which forces the gradients to be recursively computed. This commonly causes NaN gradients, which is why the recommended option is "with_grad": False in the tutorial. One detach() alleviates this issue, enabling gradient-based optimization.

NOTE: this has NOT been ablated, since the non-grad optimization is extremely computationally demanding.

Test Plan

Unit tests and benchmarking.

Related PRs

First of a couple!

Bonus: while benchmarking, I had issues repro'ing the LogEI performance initially. I found that sample_around_best made LogEI worse on Mich5. All experiments are otherwise a repro of the settings used in the LogEI paper.
LogEI_sample_around_best

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

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

@sdaulton
Copy link
Contributor

Thanks! It seems like sample_around_best could definitely lead to the AF optimization getting stuck in a local optima

@codecov
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.99%. Comparing base (ee328f2) to head (70d12de).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2748   +/-   ##
=======================================
  Coverage   99.99%   99.99%           
=======================================
  Files         219      219           
  Lines       20887    20893    +6     
=======================================
+ Hits        20886    20892    +6     
  Misses          1        1           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hvarfner
Copy link
Contributor Author

@sdaulton for sure! I currently observe similar things for JES, but I'm not sure whether the found points are actually higher in acquisition function value or not (for either LogEI or JES)

@sdaulton
Copy link
Contributor

That would be interesting to see

Copy link
Contributor

@saitcakmak saitcakmak left a comment

Choose a reason for hiding this comment

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

Hi Carl! This seems like a decent improvement. Just a few comments in-line

@facebook-github-bot
Copy link
Contributor

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

@hvarfner hvarfner force-pushed the optimize_posterior_samples branch 3 times, most recently from ef6822d to 6b3002b Compare February 25, 2025 09:49
facebook-github-bot pushed a commit that referenced this pull request Feb 25, 2025
…tions (0/N) - Restructuring of sampling methods (#2753)

Summary:
Reshuffling of sampling methods that are not directly related to acquisition function optimization (i.e., don't take it as an argument) based on [this discussion](#2748 (comment)). To remove code duplication specifically related to optimization of info-theoretic acquisition functions, this seemed like sensible moves!

Pull Request resolved: #2753

Test Plan:
Moved unittests and added new one for `boltzmann_sample`, which was used throughout and is once again used in subsequent PRs.

## Related PRs

First of a series, like [this one](#2748).

Reviewed By: esantorella

Differential Revision: D70131981

Pulled By: saitcakmak

fbshipit-source-id: 48dd86e7e06006054294d7cd8b9a3d318b0b0ad1
@hvarfner hvarfner force-pushed the optimize_posterior_samples branch from 6b3002b to 9d39469 Compare February 25, 2025 20:08
@facebook-github-bot
Copy link
Contributor

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

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

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

@hvarfner hvarfner force-pushed the optimize_posterior_samples branch from a2a2b46 to d2ee1de Compare February 27, 2025 20:47
@facebook-github-bot
Copy link
Contributor

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

hvarfner added a commit to hvarfner/botorch that referenced this pull request Nov 19, 2025
…tions (1/N)

Summary:
A series of improvements directed towards improving the performance of PES & JES, as well as their MultiObj counterparts.

## Motivation
As pointed out by SebastianAment in [this paper](https://arxiv.org/pdf/2310.20708), the BoTorch variant of JES, and to an extent PES, is brutally slow an suspiciously ill-performing. To bring them up to their potential, I've added a series of performance improvements:

**1. Improvement to get_optimal_samples and optimal_posterior_samples**: As this is an integral part of their efficiency, I've added `suggestions` (similar to `sample_around_best`) to `optimize_posterior_samples`. 
Marginal runtime improvement in acquisition optimization (sampling time practically unchanged):
![runtime_pr1](https://github.com/user-attachments/assets/a4e6d24b-2d77-4f6f-bb79-4dea8ac9304a)
Substantial performance improvement: ![pr1_regret](https://github.com/user-attachments/assets/d534f716-9a78-43db-acf4-3a795ca1e597).



**2. Added initializer to acquisition funcction optimization**: Similar to KG, ES methods have sensible suggestions for acquisition function optimization in the form of the sampled optima. This drastically reduces the time of acquisition function optimization, which could on occasion take 30+ seconds when `num_restarts` was large `>4`.

Benchmarking INC

**2b. Multi-objective support for initializer**: By re-naming arguments of the multi-objective variants, we get consistency and support for MO variants.

**3. Enabled gradient-based optimization for PES**: The current implementation contains a while-loop which forces the gradients to be recursively computed. This commonly causes NaN gradients, which is why the recommended option is `"with_grad": False` in the tutorial. One `detach()` alleviates this issue, enabling gradient-based optimization. 

NOTE: this has NOT been ablated, since the non-grad optimization is extremely computationally demanding.

X-link: meta-pytorch#2748

Reviewed By: saitcakmak

Differential Revision: D69787454

Pulled By: hvarfner
@hvarfner hvarfner force-pushed the optimize_posterior_samples branch from d2ee1de to 7ac20d8 Compare November 19, 2025 15:40
@meta-codesync
Copy link

meta-codesync bot commented Nov 19, 2025

@hvarfner has exported this pull request. If you are a Meta employee, you can view the originating Diff in D69787454.

…tions (1/N) (meta-pytorch#2748)

Summary:

A series of improvements directed towards improving the performance of PES & JES, as well as their MultiObj counterparts.

## Motivation
As pointed out by SebastianAment in [this paper](https://arxiv.org/pdf/2310.20708), the BoTorch variant of JES, and to an extent PES, is brutally slow an suspiciously ill-performing. To bring them up to their potential, I've added a series of performance improvements:

**1. Improvement to get_optimal_samples and optimal_posterior_samples**: As this is an integral part of their efficiency, I've added `suggestions` (similar to `sample_around_best`) to `optimize_posterior_samples`. 
Marginal runtime improvement in acquisition optimization (sampling time practically unchanged):
![runtime_pr1](https://github.com/user-attachments/assets/a4e6d24b-2d77-4f6f-bb79-4dea8ac9304a)
Substantial performance improvement: ![pr1_regret](https://github.com/user-attachments/assets/d534f716-9a78-43db-acf4-3a795ca1e597).



**2. Added initializer to acquisition funcction optimization**: Similar to KG, ES methods have sensible suggestions for acquisition function optimization in the form of the sampled optima. This drastically reduces the time of acquisition function optimization, which could on occasion take 30+ seconds when `num_restarts` was large `>4`.

Benchmarking INC

**2b. Multi-objective support for initializer**: By re-naming arguments of the multi-objective variants, we get consistency and support for MO variants.

**3. Enabled gradient-based optimization for PES**: The current implementation contains a while-loop which forces the gradients to be recursively computed. This commonly causes NaN gradients, which is why the recommended option is `"with_grad": False` in the tutorial. One `detach()` alleviates this issue, enabling gradient-based optimization. 

NOTE: this has NOT been ablated, since the non-grad optimization is extremely computationally demanding.

X-link: meta-pytorch#2748

Test Plan:
Unit tests and benchmarking.

## Related PRs

First of a couple!

Bonus: while benchmarking, I had issues repro'ing the LogEI performance initially. I found that `sample_around_best` made LogEI worse on Mich5. All experiments are otherwise a repro of the settings used in the LogEI paper.
![LogEI_sample_around_best](https://github.com/user-attachments/assets/d70b1494-7cf8-462d-9754-4f43088b25c4)

Reviewed By: saitcakmak

Differential Revision: D69787454

Pulled By: hvarfner
@hvarfner hvarfner force-pushed the optimize_posterior_samples branch from 7ac20d8 to 70d12de Compare November 19, 2025 15:41
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 meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants