Skip to content

Tweak distribution of diskann-wide float tests. - #1305

Open
hildebrandmw wants to merge 3 commits into
mainfrom
mhildebr/distribution
Open

Tweak distribution of diskann-wide float tests.#1305
hildebrandmw wants to merge 3 commits into
mainfrom
mhildebr/distribution

Conversation

@hildebrandmw

Copy link
Copy Markdown
Contributor

The Finite distribution for generating floating point numbers in the diskann-wide random 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-commenter

codecov-commenter commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.68%. Comparing base (b7cf3b0) to head (1963688).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1305   +/-   ##
=======================================
  Coverage   90.68%   90.68%           
=======================================
  Files         515      516    +1     
  Lines       99230    99233    +3     
=======================================
+ Hits        89987    89990    +3     
  Misses       9243     9243           
Flag Coverage Δ
miri 90.68% <100.00%> (+<0.01%) ⬆️
unittests 90.36% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-wide/src/test_utils/distribution.rs 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants