Skip to content

bug: IVF_HNSW_PQ recall assertions fail intermittently because k-means init is unseeded #8764

Description

@jackylee-ch

test_create_ivf_hnsw_pq_4bit and test_create_ivf_hnsw_pq_multivec fail their
assert_ge!(recall, 0.5) check intermittently, on main as well as on PRs.

Observed in the last day:

where test recall
main 91aee6f91, linux-build test_create_ivf_hnsw_pq_4bit::case_3_dot 0.4
PR #8431, mac-build (stable) test_create_ivf_hnsw_pq_4bit::case_3_dot 0.4
PR #8755, linux-arm test_create_ivf_hnsw_pq_multivec 0.3

Each run was otherwise green (e.g. 3146 passed, 1 failed), and the failing test
differs by runner, so this is not a regression from any one change.

The input is already deterministic: make_seeded_vector_batch
(rust/lance/src/index/vector/ivf/v2.rs:2615) pins Seed::from(42). The variance
comes from index training instead — rust/lance-index/src/vector/kmeans.rs:930
reads

// TODO: use seed for Rng.
let mut rng = SmallRng::from_os_rng();

so centroid initialization differs every run. With K = 10 the recall metric
moves in steps of 0.1 and the threshold is 5 of 10 neighbours, so a slightly
worse set of centroids flips the assertion.

Threading a seed through KMeansParams for the test path would make these
deterministic, which the existing TODO already anticipates. Lowering the
threshold would also stop the failures but would weaken the check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions