Skip to content

Commit

Permalink
Fix qNEI with Derivative Enabled BO (#1716)
Browse files Browse the repository at this point in the history
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to make BoTorch better.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to BoTorch here: https://github.com/pytorch/botorch/blob/main/CONTRIBUTING.md
-->

## Motivation

Derivative enabled GPs allow for faster convergence rates. This is well studied in the literature and makes intuitive sense since a lot more information is provided with each objective function evaluation. I want code to be available for myself and other future researchers who want to explore derivative enabled GPs.

This PR resolves an error with the qNEI acquisition function for derivative enabled GPs. For more information, see [here](#1679).

### Have you read the [Contributing Guidelines on pull requests](https://github.com/pytorch/botorch/blob/main/CONTRIBUTING.md#pull-requests)?

Yes, this doesn't affect the outcome of the unit tests, though when I run the unit tests on an unmodified branch of *main* I get `110 failed, 853 passed, 1165 warnings`.

Pull Request resolved: #1716

Test Plan:
I have some files from an issue ([1679](#1679)) I opened which show a simple case where a derivative-enabled Gaussian Process fails to find the qNEI value at a point where an equivalent non-derivative-enabled Gaussian Process does not fail.

- [shared.py.txt](https://github.com/pytorch/botorch/files/10820140/shared.py.txt)
- [Simple_Repro_non_D_2.py.txt](https://github.com/pytorch/botorch/files/10820141/Simple_Repro_non_D_2.py.txt)
- [Simple_Repro_non_D.py.txt](https://github.com/pytorch/botorch/files/10820142/Simple_Repro_non_D.py.txt)

Adding the fix in this PR removes the error.

Please let me know if I should add a specific unit test for this.

## Related PRs

N/A

Reviewed By: SebastianAment

Differential Revision: D43822902

Pulled By: esantorella

fbshipit-source-id: 0876bebb9364fca6c10379d92e792cb2dc9865e1
  • Loading branch information
yyexela authored and facebook-github-bot committed Mar 11, 2023
1 parent eaa6fb2 commit 0b744dd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions botorch/posteriors/gpytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from linear_operator import settings as linop_settings
from linear_operator.operators import (
BlockDiagLinearOperator,
DenseLinearOperator,
LinearOperator,
SumLinearOperator,
)
Expand Down Expand Up @@ -323,6 +324,7 @@ def scalarize_posterior_gpytorch(
if isinstance(cov_scaled, LinearOperator):
cov_scaled = cov_scaled.to_dense()
new_cov = cov_scaled.view(sum_shape).sum(dim=sum_dims[0]).sum(dim=sum_dims[1])
new_cov = DenseLinearOperator(new_cov)

return new_mean, new_cov

Expand Down

0 comments on commit 0b744dd

Please sign in to comment.