-
Notifications
You must be signed in to change notification settings - Fork 414
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
[Feature Request] Derivative Enabled GPs #1679
Comments
Hi @yyexela, great to see you interested in using derivative-enabled GPs with other acquisition functions. The error you're getting suggests that there may be numerical problems unrelated to the fact that this is using derivative-enabled GPs. On the other hand, we haven't really battle tested derivative-enabled GPs, so there may also be something else going on. Could you provide a simple repro of the issue you're running into? |
Also cc @pabloprf re derivative-enabled GPs. |
Sure! I have two examples ready, one with derivative information (Simple_Repro_D.py.txt) and one without (Simple_Repro_non_D.py.txt). The first fails at |
I think I'm getting close... I have three files which I'm using for testing. One file just has shared functions, the other two define the models. One model is without derivatives, the other is with derivatives, but both use GPyTorch without calling a BoTorch model directly (though they both sub-class GPyTorchModel): With this, (and lots of print statements in the source code) I can see that the non-derivative version (I call it non-D) eventually calls
Tracking the path of the code for the derivative-enabled case (I call it yes-D), I see that the same function is not called. This is because the function gets called in
while for the yes-D case, this is not true. This results in a call to
which makes sense, since in my test example from the code above, there are six rows, the last one being identical to the first one! So, I have the following questions:
Thanks again and let me know if something wasn't clear! |
Sweet! So I have a PR opened which resolves the issues I was having with the Cholesky decomposition. The simple fix I added makes it so that the Cholesky decomposition is calculated from the The matrix was not positive-definite, because as I mentioned above, two rows of the covariance matrix were identical if the acquisition function was being evaluated at a point that was evaluated on the objective function earlier. I'll go ahead and start working on getting KG working too, let me know what else I can do! For example, if there are any issues in the PR:) |
Nice work tracking down this issue! It seems a bit weird to me to fix this by wrapping the covariance in a I think we can consider merging this if it doesn't cause any issues also on our end, since the overhead of this should be very small. But we should also take a closer look at this - ideally we'd be able to just use torch @SebastianAment - curious if you have any thoughts on this. |
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
@yyexela with the fix landed, is there anything outstanding on this feature request or can this be closed out? |
Great! Yes, I want to also get KG working with derivative GPs and after that I can make a tutorial notebook and then I think this could be closed out. The fix just gets qNEI working. |
I'll get to work on a tutorial notebook now that #2317 merged:) |
Amazing! |
@yyexela checking in if you had a chance to work on this tutorial? |
Hey! Sorry, yes, I had something working and life got in the way, I'll try to get something pushed in the next week or so. Thanks for checking in! |
@Balandat Found my tutorial and it still works so I was able to get it in sooner than planned:) |
Where can I see the versions of the packages installed for the smoke test? I was able to run my notebook just fine locally with a fresh conda environment and latest package versions, but got an error in my PR... |
Let's move this discussion onto the PR, will respond there. |
🚀 Feature Request
Hello, I'm interested in studying GPs with derivatives, similar to the example provided in this notebook provided in this issue. However, the previous notebook uses LogEI on noisy data, which isn't optimal. As such, I want to be able to use both qNEI and KG on noisy data using this derivative-enabled GP in BoTorch.
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.
Pitch
Ideally, I would want to see a BoTorch model for GPs with derivative information that work without any issues when used with qNEI and KG. I want this implemented for my research and I have a significant amount of time I can contribute to implementing this myself. However, I'm not sure where to even begin since I'm not familiar with the code-base for BoTorch. I don't want to spend lots of time looking in the wrong place for implementing this, so I would appreciate any and all help! My current issue is trying to get qNEI to work. I've added
self._num_outputs = 1+d
to my derivative enabled GP class, but I'm getting the following error:torch._C._LinAlgError: linalg.cholesky: (Batch element 0): The factorization could not be completed because the input is not positive-definite (the leading minor of order 6 is not positive-definite).
which I'm trying to resolve. As I've mentioned earlier, however, I'm not sure this is the right place to look. Thanks!
Are you willing to open a pull request? (See CONTRIBUTING)
Yes
Additional context
I also briefly looked into sub-classing
BatchedMultiOutputGPyTorchModel
for my model, but the documentation says the outputs are independent, which I don't think applies to derivative enabled GPs. However, when I subclassed this I got another error:RuntimeError: Cannot yet add fantasy observations to multitask GPs, but this is coming soon!
which led me to this issue from 4 years ago mentioning a similar problem to what I'm having.
Thanks again!
The text was updated successfully, but these errors were encountered: