Tweak distribution of diskann-wide float tests. - #1305
Open
hildebrandmw wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the diskann-wide floating-point Finite test distribution to remove an unintended bias caused by reusing the same random bits for both “kind selection” (normal/subnormal/zero) and the generated value’s bit-pattern.
Changes:
- Split “kind selection” entropy from the generated float’s bit-pattern by sampling a wider integer and partitioning it into upper/lower bits.
- Replace the old non-power-of-two modulo weighting (100) with a power-of-two bucket count (128) to eliminate modulo-induced bias.
- Update the distribution tests’ expected weights to match the adjusted bucket thresholds.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+71
to
+83
| // Generate a uniformly distributed integer. | ||
| // | ||
| // This integer is twice as large as what's actually needed to generate | ||
| // | ||
| // * the value that will be used to make the final floating point number | ||
| // (the lower bits). | ||
| // | ||
| // * a selector for the kind of floating point number we are going to | ||
| // generate (the upper bits). | ||
| // | ||
| // Generating a number twice as big allows us to perform just a single sample | ||
| // from the random number generator without biasing the result. | ||
| let twice: $twice = StandardUniform {}.sample(rng); |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1305 +/- ##
=======================================
Coverage 90.68% 90.68%
=======================================
Files 515 516 +1
Lines 99230 99233 +3
=======================================
+ Hits 89987 89990 +3
Misses 9243 9243
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Finitedistribution for generating floating point numbers in thediskann-widerandom tests is slightly biased: the same value is used to select the kind of floating-point number and the value of that number. Practically speaking, the bias is relatively small - but it does mean that some valid floating-point bit patterns cannot be created.This PR fixes that by splitting the kind generation from the value generation. As a side-effect, it also removes the tiny bias introduced by the modulo. This does mean that normal numbers have a slightly higher fraction of the generated values, but not significantly.