Tweak distribution of diskann-wide float tests. - #1305
Tweak distribution of diskann-wide float tests.#1305Mark Hildebrand (hildebrandmw) wants to merge 6 commits into
diskann-wide float tests.#1305Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1305 +/- ##
==========================================
- Coverage 91.46% 91.27% -0.20%
==========================================
Files 516 517 +1
Lines 98200 98517 +317
==========================================
+ Hits 89820 89919 +99
- Misses 8380 8598 +218
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| // | ||
| // 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); |
There was a problem hiding this comment.
The aggregate frequency checks do not directly cover the regression this change fixes: selector/payload independence. An implementation that accidentally reused the lower bits for both could restore correlated or unreachable float bit patterns while preserving the tested category totals. Please add a deterministic RNG regression test for both f16 and f32 that controls the upper selector bits and lower payload bits independently, verifying that each half can vary without influencing the other.
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.