-
Notifications
You must be signed in to change notification settings - Fork 419
OptimizationGradientError #2537
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
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 for putting this up - this makes sense to me.
Im also thinking about catching the error in timeout.py as the OptimizationTimeoutError, throwing a warning and returning a result of the optimization. What do you think about this? I think this could be a useful and elegant way of dealing with it.
Yeah I think this generally make sense. One issue with warnings is that they're often overlooked or ignored - so I wouldn't want to change the default behavior that something that would previously throw an error would now just return a result. But maybe it could be gated by some raise_on_nan
flag?
Co-authored-by: Max Balandat <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2537 +/- ##
=======================================
Coverage 99.98% 99.98%
=======================================
Files 193 193
Lines 17000 17005 +5
=======================================
+ Hits 16998 17003 +5
Misses 2 2 ☔ View full report in Codecov by Sentry. |
@Balandat has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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! I'm all for making it easier to debug optimization errors :)
I think it is also fine as it is now, advanced users can now catch the error and see which is the |
Motivation
I am currently experimenting with some custom kernels, which exhibit some numeric instabilities, which lead in some situations during optimization to
NaN
s in the gradient. To better examine these situations, I thought it could be nice if the error which is thrown in this situation also contains the current x which leads to theNaN
s in the gradient. For this purpose, I implemented anOptimizationGradientError
like theOptimizationTimeoutError
which holds the current x.Im also thinking about catching the error in
timeout.py
as theOptimizationTimeoutError
, throwing a warning and returning a result of the optimization. What do you think about this? I think this could be a useful and elegant way of dealing with it.Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Unit tests.