Skip to content

tests: make the PQ approximate-search tests ask for every row - #150

Merged
tae898 merged 1 commit into
mainfrom
test/149-pq-approximate-deterministic
Oct 30, 2026
Merged

tae898 merged 1 commit into
mainfrom
test/149-pq-approximate-deterministic

Conversation

@tae898

@tae898 tae898 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #149

TestFindNearestApproximate asserted the first name of find_nearest_approximate with k=1 and k=3 on a four-row PRODUCT index. The approximate path has no re-rank (rerank_oversample applies to find_nearest, not here): it returns the PQ scores of whatever the walk collected. Both tests now ask for k = len(PQ_VECTORS), so the answer is the PQ ranking of all four rows, and a smaller k asserts only the count, the float distance and the order. The assertion on the first name is unchanged, not loosened, and the code path is shared by the JVM and native backends (vector.py and _native/schema_objects.py), both checked below.

Repetition with pytest-repeat --count 200 on both tests (400 test runs per cell), taskset -c 4,5 nice -n 19, Python 3.14:

backend before after
JVM wheel 0 of 400 failed 0 of 400 failed
native wheel 0 of 400 failed 0 of 400 failed

The flake did not reproduce on this host, so the before column does not prove the cause, and I am stating that rather than claiming a proven mechanism. What I ruled out: jvector's KMeansPlusPlusClusterer on the globally centered four rows gave four distinct centroids in 20000 of 20000 runs (unweighted, and anisotropic 0.2 and 0.5), and 1200 fresh index builds returned an identical ranking and scores. The remaining run-to-run variable is how much of the four-node graph a small k collects, which is what the change removes from the test. If the failure shows again after this, the issue should be reopened with the job log.

🤖 Generated with Claude Code

TestFindNearestApproximate asserted the first name of find_nearest_approximate with k=1 and k=3 on a four-row index. The approximate path has no re-rank (it returns the PQ scores of what the walk collected), so the only run-to-run variable the test left open was how much of the four-node graph a small k collects. Both tests now ask for k = number of rows, so the answer is the PQ ranking of all four rows, and a smaller k only asserts count and order.

Repetition (pytest-repeat --count 200, both tests, taskset -c 4,5, Python 3.14), before and after: JVM wheel 0 of 400 failed before, 0 of 400 after; native wheel 0 of 400 before, 0 of 400 after. The flake did not reproduce on this host, so the before numbers do not prove the cause. Ruled out: jvector's KMeansPlusPlusClusterer on the globally centered four rows gave four distinct centroids in 20000 of 20000 runs (unweighted, anisotropic 0.2 and 0.5), and 1200 fresh index builds returned the same ranking and scores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tae898
tae898 merged commit 4e9e9b3 into main Oct 30, 2026
36 checks passed
@tae898
tae898 deleted the test/149-pq-approximate-deterministic branch October 30, 2026 05:05
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.

Flaky test: TestFindNearestApproximate first result can be y instead of x (PQ on three vectors)

1 participant