Skip to content

test(index): make IVF_HNSW_PQ recall fixture deterministic - #11120

Merged
Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-ivf-hnsw-pq-recall-fixture-20261116
Nov 16, 2026
Merged

Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-ivf-hnsw-pq-recall-fixture-20261116

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

The test_create_ivf_hnsw_pq fixture is stochastic: its live index build samples four IVF training rows and initializes the IVF and PQ k-means models from OS entropy. Recall is therefore a random variable, and the existing recall >= 0.5 assertion occasionally sees 0.45. The same test failed with that signature on ARM in #10977 and on x86 in #10716; the test, training and lockfile inputs are identical at those heads, their bases and current main.

This is a test-only change. The test now trains the IVF model from four fixed rows of the same fixture with train_ivf_model_from_sample, trains the PQ codebook on the corresponding residuals with PQBuildParams::build, and passes both models to create_index. The live build therefore no longer consumes training entropy, while the index parameters (nlist=2, sample_rate=2, max_iters=2, PQ 4x8, HNSW 3/8/32), the query (k=20, nprobes=2, ef=64), the recall >= 0.5 threshold, ground truth, HNSW construction, PQ encoding and scan path are unchanged.

Training coverage is retained: both production trainers execute in this test, and their independent exact-output tests remain (vector::kmeans::tests::test_flat_kmeans_seed_is_reproducible, vector::pq::builder::tests, and the train_ivf_from_sample_* cases).

Validation:

  • Before: 15 independent-process runs passed with instrumented recall 0.60-0.85; the 0.45 CI tail was not reproduced locally, matching the prior 200-run measurement.
  • After: 10 independent-process runs of the fixed-model fixture produced identical results with recall 0.80; the final test code passed 15/15 unmodified runs (5 before and 10 after the temporary recall print was removed).
  • Neighbor tests: IVF/HNSW/PQ lifecycle cases, test_create_index_nulls, PQ builder and seeded-kmeans tests passed.
  • cargo fmt --all -- --check
  • cargo clippy --all --tests --benches --profile ci --locked --features "$ALL_FEATURES" -- -D warnings

Limits: the failing CI run did not log its sampled rows or initial centroids, so the exact draw cannot be replayed. ARM was not run locally; the hosted Rust ARM job on this PR is the platform check.

Refs #8764

The fixture's live build sampled IVF training rows and initialized the IVF and PQ k-means models from OS entropy, so recall was a random variable that occasionally fell below the existing 0.5 assertion.\n\nTrain both models from fixed rows of the same fixture with the production trainers, then build the index with them. The index parameters, recall threshold, HNSW construction and scan path remain unchanged.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added the chore label Nov 16, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

✅ Gate recommendation: approve.

Fixed training inputs remove the stochastic training choices while preserving the recall threshold and indexed search coverage. No blockers found.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 16, 2026
@Xuanwo
Xuanwo merged commit b9780b7 into main Nov 16, 2026
45 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/fix-ivf-hnsw-pq-recall-fixture-20261116 branch November 16, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants