Skip to content

test(vector): tolerate SIMD distance rounding#7829

Merged
BubbleCal merged 1 commit into
mainfrom
yang/fix-vector-index-distance-range-flake
Jul 17, 2026
Merged

test(vector): tolerate SIMD distance rounding#7829
BubbleCal merged 1 commit into
mainfrom
yang/fix-vector-index-distance-range-flake

Conversation

@BubbleCal

Copy link
Copy Markdown
Contributor

What is the bug?

test_vector_index_distance_range requires exact equality between brute-force and indexed float32 distances. The two paths can use different scalar and runtime-dispatched SIMD reduction orders, producing a few ULPs of rounding difference even when the results are equivalent.

What issues does this cause?

The test fails intermittently on x86 CI across unrelated changes, while the returned IDs, ordering, and distance-range checks all pass.

How does this PR fix the problem?

Use a relative tolerance of 1e-5 for the distance comparison while retaining atol=0.0. This matches the expected precision of the alternative float32 kernels without weakening the range or result checks.

Validation

  • uv run pytest python/tests/test_vector_index.py::test_vector_index_distance_range -q
  • uv run make lint

@github-actions github-actions Bot added A-python Python bindings chore labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: a08d79bf-3f3e-4e4b-8834-4776908d84ff

📥 Commits

Reviewing files that changed from the base of the PR and between f868f51 and cb37c3c.

📒 Files selected for processing (1)
  • python/python/tests/test_vector_index.py

📝 Walkthrough

Walkthrough

The vector index distance-range test now compares brute-force and index-based distances with a relative tolerance of 1e-5 while retaining an absolute tolerance of 0.0.

Changes

Vector distance testing

Layer / File(s) Summary
Relax distance comparison tolerance
python/python/tests/test_vector_index.py
The distance assertion now allows small relative floating-point differences instead of requiring exact equality.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: xuanwo, wjones127

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: relaxing SIMD distance rounding tolerance in vector tests.
Description check ✅ Passed The description matches the change and explains the bug, fix, and validation steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yang/fix-vector-index-distance-range-flake

Comment @coderabbitai help to get the list of available commands.

@BubbleCal
BubbleCal marked this pull request as ready for review July 17, 2026 03:52
@BubbleCal
BubbleCal merged commit c6d1b95 into main Jul 17, 2026
15 checks passed
@BubbleCal
BubbleCal deleted the yang/fix-vector-index-distance-range-flake branch July 17, 2026 05:44
wjones127 pushed a commit that referenced this pull request Jul 21, 2026
## What is the bug?

`test_vector_index_distance_range` requires exact equality between
brute-force and indexed `float32` distances. The two paths can use
different scalar and runtime-dispatched SIMD reduction orders, producing
a few ULPs of rounding difference even when the results are equivalent.

## What issues does this cause?

The test fails intermittently on x86 CI across unrelated changes, while
the returned IDs, ordering, and distance-range checks all pass.

## How does this PR fix the problem?

Use a relative tolerance of `1e-5` for the distance comparison while
retaining `atol=0.0`. This matches the expected precision of the
alternative `float32` kernels without weakening the range or result
checks.

## Validation

- `uv run pytest
python/tests/test_vector_index.py::test_vector_index_distance_range -q`
- `uv run make lint`

Co-authored-by: Yang Cen <[email protected]>
(cherry picked from commit c6d1b95)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-python Python bindings chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants