-
Notifications
You must be signed in to change notification settings - Fork 456
Handle NotPSDError and hitting maxiter in fit_gpytorch_model #1007
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
Conversation
Balandat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this makes a lot of sense to me! A few comments inline, but this looks good overall.
Codecov Report
@@ Coverage Diff @@
## main #1007 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 110 110
Lines 8562 8570 +8
=========================================
+ Hits 8562 8570 +8
Continue to review full report at Codecov.
|
|
@Balandat has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
Looks like we lost a tiny bit of test coverage since we don't actually fail fitting anymore other than with the NonPSDError. Would you mind adding a test for that (e.g.. fail with some other exception)? |
|
@saitcakmak has updated the pull request. You must reimport the pull request before landing. |
|
I didn't realize we needed |
|
@Balandat has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
…torch#1007) 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 The current behavior of `fit_gpytorch_model` is to error out when it receives a `NotPSDError` and to count hitting `maxiter` during optimization as an optimization failure. Labeling `maxiter` as an optimization failure leads to retrying the model fit, and likely reaching `maxiter` in each try and labeling all tries as failures. This ends up using more effort than the user intended to (by passing in `maxiter` in the first place), while offering no real benefit. The proposed solution here is to simply count hitting `maxiter` as a successful model fit and to return the fit obtained with the given budget. The `NotPSDError` during model fit is one of the most common reasons that leads to me having to restart an experiment. What I observed is that when the first try raises `NotPSDError`, a second try starting from initial parameters sampled from the priors will most of the time produce a successful model fit. So, this proposes to catch the `NotPSDError` and retry the model fit with new initial parameter values. ### Have you read the [Contributing Guidelines on pull requests](https://github.com/pytorch/botorch/blob/main/CONTRIBUTING.md#pull-requests)? Yes Pull Request resolved: meta-pytorch#1007 Test Plan: Unittests. ## Related PRs (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.) cc sdaulton Reviewed By: sdaulton Differential Revision: D32798598 Pulled By: Balandat fbshipit-source-id: fa70b5c9b4d12673441f2a1842d1c9a3807687a1
Motivation
The current behavior of
fit_gpytorch_modelis to error out when it receives aNotPSDErrorand to count hittingmaxiterduring optimization as an optimization failure.Labeling
maxiteras an optimization failure leads to retrying the model fit, and likely reachingmaxiterin each try and labeling all tries as failures. This ends up using more effort than the user intended to (by passing inmaxiterin the first place), while offering no real benefit. The proposed solution here is to simply count hittingmaxiteras a successful model fit and to return the fit obtained with the given budget.The
NotPSDErrorduring model fit is one of the most common reasons that leads to me having to restart an experiment. What I observed is that when the first try raisesNotPSDError, a second try starting from initial parameters sampled from the priors will most of the time produce a successful model fit. So, this proposes to catch theNotPSDErrorand retry the model fit with new initial parameter values.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Unittests.
Related PRs
(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.)
cc @sdaulton