Handle -inf and inf values in RDBStorage#3238
Conversation
This patch ensures that `RDBBackend` can fully support MySQL specification by representing infinite values as floats and limiting signed floats to 32 bit
-inf and 'inf' values in RDBStorage-inf and inf values in RDBStorage
|
Note - this is a simple way of fixing it without a need to modify data models. The downside is that when translating value from storage back to actual value, we can't directly compare two floats. This means some trial values that are close enough to numerical limits might be translated back as infinite. But still, this is for values close to Alternative solution is to modify |
|
@nzw0301 @HideakiImamura Could you review this PR, please? |
|
Sure. I'll review this PR within the next week. |
HideakiImamura
left a comment
There was a problem hiding this comment.
Thanks for the PR. Basically, LGTM. Let me add a comment for the test.
Codecov Report
@@ Coverage Diff @@
## master #3238 +/- ##
==========================================
+ Coverage 91.51% 91.58% +0.06%
==========================================
Files 146 145 -1
Lines 12011 12011
==========================================
+ Hits 10992 11000 +8
+ Misses 1019 1011 -8
Continue to review full report at Codecov.
|
HideakiImamura
left a comment
There was a problem hiding this comment.
Thanks for the update! LGTM.
|
I confirmed that all problems in #3206 are resolved by this PR. |
nzw0301
left a comment
There was a problem hiding this comment.
Thank you for your PR! LGTM.
I locally confirmed the code works with
- a single objective (
inf) with intermediate values (inf) - two objective values (
inf, 1.0).
I'm wondering if we could add the explanation of this transformation to Optuna documentation, where storage or study. But it can be addressed as a follow-up.
So I'll merge this PR once.
Motivation
Previously an error could be raised when
-inforinfwas registered in rdb storage. Depending on SQL dialect in backend, those special values might be supported or not. This PR introduces a simple way to get around this limitation by storing-infandinfas minimum and maximum values of 32 bit float and providing thin translation layer between stored and true values on database reads and writes. This gives effective available range for trial values of(-3.4028235e+38, 3.4028235e+38). Everything beyond that is interpreted as infinity. Closes #3206.Description of the changes
infhandling inRDBStorage