fix(test): tolerate boundary-tie in IVF distance_range assertions#6999
Merged
BubbleCal merged 1 commit intoMay 29, 2026
Merged
Conversation
The IVF distance_range test partitions top-k results around `part_dist` using a strict-less left filter (`d < part_dist`) and an inclusive right filter (`d >= part_dist`). When the boundary vector ties with the adjacent one (`dists[part_idx - 1] == dists[part_idx]`), the partition becomes ambiguous: the strict-less filter excludes both tied vectors, shifting one row from left to right and dropping the trailing row off right_res's limit. This surfaced on linux-arm for `test_build_ivf_pq::case_3` (DistanceType::Dot) because ARM SIMD FMA produces tied float32 dot products that x86's separate mul+add does not, making the failure deterministic per architecture but architecture-dependent. Detect the tie explicitly and weaken the count and row-id assertions for the affected positions only. The distance-value assertions remain unconditional and still verify partition correctness in both cases.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
test_build_ivf_pq::case_3(DistanceType::Dot) fails on linux-arm with:The test partitions top-k results around
part_dist = dists[part_idx]using:d < part_dist, limitpart_idxd >= part_dist, limitk - part_idxIt then asserts
left_res.num_rows() == part_idxand that the row-id ordering matches the original top-k.Root cause
When
dists[part_idx - 1] == dists[part_idx], two vectors tie at the partition boundary:left_reshaspart_idx - 1rowsright_res's limitThe failure is deterministic per architecture but architecture-dependent because ARM NEON uses fused multiply-add (FMA) for SIMD dot products by default, while x86 (without
-mfma) does separate mul+add. FMA produces a single rounding fora*b + c; separate ops produce two. For Dot distance specifically — which has fewer transformations than L2 or Cosine — this ULP-level difference is enough to make two distances tie on ARM that don't tie on x86. Random vectors generated fromStdRng::seed_from_u64([13; 32])happen to hit such a tie at the partition boundary on ARM.Fix
Detect the tie explicitly (
dists[part_idx - 1] == part_dist) and weaken the count and row-id assertions for the affected positions only. The unconditional distance-value assertions immediately below (left_dists < part_dist,right_dists >= part_dist) still verify partition correctness in both branches.Related
Similar test relaxations on this code area:
test_query_delta_indicesTest plan
cargo test -p lance --lib --release test_build_ivf_pqpasses locally on x86 macOS (exercises the no-tie branch, all 12 cases including case_3)test_build_ivf_pq::case_3(the failing case from PR feat: support Utf8View and BinaryView in encoding and filter coercion #6985)