Skip to content

fix(diskann): seed test RNGs to fix flaky test_diskann_basic#397

Merged
ruvnet merged 1 commit intomainfrom
fix/diskann-flaky-test-seed
Apr 27, 2026
Merged

fix(diskann): seed test RNGs to fix flaky test_diskann_basic#397
ruvnet merged 1 commit intomainfrom
fix/diskann-flaky-test-seed

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented Apr 27, 2026

Problem

Workspace-CI on main started failing Tests (vector-index) after the
ACORN/RaBitQ-WASM merges (#391, #394) — not due to the new code, but
because ruvector-diskann::index::tests::test_diskann_basic is flaky.

The test draws 500 random 32-dim vectors, queries with vec-42, and
asserts the nearest neighbour is vec-42 itself. With
rand::thread_rng() (unseeded), CI run 24976593452 drew an
unlucky distribution where the Vamana graph traversal returned
vec-364 instead and the assertion failed.

Fix

Replace thread_rng() with StdRng::seed_from_u64(0xD15CA77) in the
three test-only RNG sites in crates/ruvector-diskann/src/index.rs:

  • random_vectors() — used by test_diskann_basic,
    test_diskann_with_pq, test_diskann_save_load
  • test_recall_at_10
  • test_scale_5k

Now fully deterministic across runs and platforms.

Verification

  • cargo test -p ruvector-diskann --lib17/17 pass (49.6s)
  • cargo test -p ruvector-diskann --lib test_diskann_basic ×3 → all
    pass with identical timings (≈0.1s each)

No production-code changes; this is tests-only.

`test_diskann_basic` and the other random-data tests in
`crates/ruvector-diskann/src/index.rs` used `rand::thread_rng()`, so
each CI run drew different vectors. The test asserts that the nearest
neighbour of `vec-42` is `vec-42` itself; with unfavourable random
draws the ANN graph traversal happened to settle on a near-duplicate
(seen on main as `left: "vec-364"` vs `right: "vec-42"`) and the
assertion failed.

Fix: replace `thread_rng()` with `StdRng::seed_from_u64(0xD15CA77)` in
`random_vectors()`, `test_recall_at_10`, and `test_scale_5k`. Output
is fully deterministic across runs and platforms; verified locally
with three repeats of `test_diskann_basic` and the full lib-test suite
(17/17 passing in 49.6s).

No production-code changes; tests-only.
@ruvnet ruvnet merged commit c7aed50 into main Apr 27, 2026
26 of 27 checks passed
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.

1 participant