Skip to content

vectors: remove the stale per-bucket PRODUCT guard; the engine searches small buckets exactly - #177

Merged
tae898 merged 2 commits into
mainfrom
fix/remove-stale-pq-guard
Nov 1, 2026
Merged

tae898 merged 2 commits into
mainfrom
fix/remove-stale-pq-guard

Conversation

@tae898

@tae898 tae898 commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Closes #173

Removes VectorIndex._ensure_product_quantization_ready() and its calls (find_nearest, find_nearest_approximate, build_graph_now, and the native find_nearest_approximate), and the _pq_ready flag that only it used. Since ArcadeData/arcadedb#5417 the engine builds and searches a bucket with fewer vectors than pq_clusters exactly, without PQ; the guard refused that case on the JVM build and could refuse a small type on the native build.

  • core.py docstrings (quantization, pq_clusters) and how-to/vectors.adoc now state the engine behaviour: a bucket below pq_clusters builds, skips PQ and is searched exactly; at or above it, PQ is trained and the search is approximate.
  • Tests: the test that pinned the guard's error is removed; new shared tests/test_vector_product_quantization.py::TestProductQuantizationSmallBuckets::test_buckets_below_pq_clusters_build_and_search_exactly[5|15] (4 buckets, pq_clusters 16, every bucket below it): build_graph_now() succeeds and find_nearest_approximate and find_nearest both return the exact top-5 of a plain-Python cosine ranking, with matching scores.

Evidence (the measurement in #173): with the guard bypassed, the JVM build gives exactly what the native build gives at 5, 15, 16, 17 and 40 vectors per bucket. Against the 26.11.1.dev0 wheels of main the new test fails on the JVM wheel (the guard's "requires at least pq_clusters" error, both parameters) and passes on the native wheel.

🤖 Generated with Claude Code

tae898 and others added 2 commits November 1, 2026 21:14
_ensure_product_quantization_ready (added in fc44025 for ArcadeData/arcadedb#3723)
raised "requires at least pq_clusters indexed vectors per bucket" on the JVM build,
and on the native build refused a whole type with fewer than pq_clusters vectors.
Since ArcadeData/arcadedb#5417 (b37d610cd0) the engine skips PQ for such a bucket
and searches it exactly, so the guard only blocks a working path. Measured on both
26.11.1.dev0 wheels with the guard bypassed: below pq_clusters per bucket the build
succeeds and find_nearest_approximate returns the exact neighbours with exact scores;
from pq_clusters up PQ is trained.

Remove the method, its cache flag and its callers, fix the two docstrings and the
vectors how-to page, drop the test that pinned the raise, and add a shared test of
the engine behaviour (4 buckets, 5 and 15 vectors each, pq_clusters 16).

Against the main 26.11.1.dev0 wheels the new small-bucket test fails on the JVM wheel (the guard raises) and passes on the native wheel, for both parameters.

Closes #173

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bandit flagged the f-string SQL of the small-bucket test; the bucket
number is a loop counter, not input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tae898
tae898 merged commit 2234e0e into main Nov 1, 2026
37 checks passed
@tae898
tae898 deleted the fix/remove-stale-pq-guard branch November 1, 2026 16:48
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.

vectors: the per-bucket PRODUCT guard refuses small buckets the engine searches exactly

1 participant