Skip to content

test(python): migrate the last seven test files off the 0.7 call forms - #230

Merged
gouyt13 merged 1 commit into
mainfrom
test/214-migrate-remaining-files
Nov 13, 2026
Merged

gouyt13 merged 1 commit into
mainfrom
test/214-migrate-remaining-files

Conversation

@gouyt13

@gouyt13 gouyt13 commented Nov 13, 2026

Copy link
Copy Markdown
Member

Closes #214

This migrates the seven remaining files off the 0.7 call forms: test_ivf.py, test_hnsw.py, test_symqg.py, test_input_boundaries.py, test_ivf_initializers.py, test_portable_indexes.py and test_import.py. #226 and #227 migrated the other eleven. Every test file except the four exempt ones (test_compat_08.py, test_txtai_compat.py, test_train_api.py, test_symqg_api.py) now passes with -W error::DeprecationWarning.

Changes

  • Constructors take no max_elements. HNSW passes nbits and num_clusters explicitly. Where a test needs room for more points, it calls resize, as in partial_hnsw.
  • build becomes set_centroids plus add:
    • Calls that relied on build's single thread pass num_threads=1.
    • Explicit thread counts and fast_quantization carry over.
    • test_ivf.py and test_hnsw.py each gain a small _built helper for the dozen or so cases that set centroids and add data.
  • Expectations that follow 0.8 behavior. What each test checks is unchanged.
    • Messages. set_centroids and HNSW add report their own messages for a wrong centroid shape or an out-of-range cluster ID.
    • Training on first add. An untrained IvfIndex trains on its first add, so "add before training raises" now passes cluster_ids, as the HNSW test already did.
    • search_batch. The SymphonyQG validation test uses search, since search_batch is a deprecated alias.
    • Access guard. In test_path_callback_runs_before_access_guard, the SymphonyQG case calls add, its only write, inside the path callback. A free guard gives the "incremental addition" error; a held guard would give Index is busy.

Moved to test_compat_08.py or deleted

Tests of behavior with no 0.8 form. Each moved test is wrapped in quietly; #213 deletes that file.

Test From Action
test_build_row_count_diagnostics test_input_boundaries.py moved
test_failed_rebuild_preserves_index test_symqg.py moved
test_successful_rebuild_replaces_index test_symqg.py moved
default init of SymqgIndex.build (one assertion) test_symqg.py moved
test_invalid_quantization_bits_raises test_symqg.py deleted: test_symqg_mixed_or_invalid_old_forms covers it
test_rejected_rebuild_preserves_index test_hnsw.py moved
test_zero_capacity_raises test_hnsw.py moved
test_rebuild_matches_incremental_encoding_with_empty_clusters test_ivf.py moved: rebuilding a loaded index through build has no 0.8 form; C++ IvfConstructionTest covers the same encoding

IVF HNSW routing threads

IvfIndex.set_centroids has no num_threads and builds the HNSW routing graph with every CPU. The 0.7 build passed its thread count through. Two tests are affected:

  • test_hnsw_centroid_routing_roundtrip (128 centroids) checks every centroid's self-recall in aggregate, at least 97%, instead of four exact matches. A parallel hnswlib build may leave a centroid unreachable (Make graph-index tests independent of graph connectivity #216).
  • test_hnsw_parallel_build_routes_and_reloads: threads now applies to add and search only.

A follow-up PR adds num_threads to IvfIndex.set_centroids. The C++ method already takes it. That PR also restores both tests.

Checks

On Linux x86-64, Xeon Gold 6418H, GCC 14.3, Release, native optimization off; the package was built from main.

  • The seven files under -W error::DeprecationWarning: 428 passed.
  • Every file except the four exempt ones under the same flag: 1,003 passed, 2 skipped.
  • Full Python suite: 1,146 passed, 2 skipped.
  • check-python.sh passes.
  • The seven files plus test_compat_08.py in a loop: 208 runs, 0 failures. These runs include the graph builds that now use every CPU.

Migrate test_ivf, test_hnsw, test_symqg, test_input_boundaries,
test_ivf_initializers, test_portable_indexes and test_import to the 0.8
API: constructors without max_elements, and set_centroids plus add in
place of build. Calls that relied on build's single thread pass
num_threads=1, and HNSW passes nbits and num_clusters explicitly.

Tests of 0.7-only behavior move to test_compat_08.py, wrapped in
quietly: build's row-count diagnostics, SymphonyQG rebuilds and build's
default init, HNSW's rejected rebuild and zero capacity, and IVF's
rebuild of a loaded index. test_invalid_quantization_bits_raises is
deleted, because test_compat_08.py already covers it.

Where 0.8 behaves differently, the expectations follow it:
set_centroids and HNSW add report their own messages, an untrained
IvfIndex trains on its first add unless cluster IDs are given, and
SymphonyQG's access-guard check uses add, its only write.

IvfIndex.set_centroids builds the HNSW routing graph with every CPU, so
the 128-centroid routing test checks self-recall in aggregate.

Every test file except the four exempt ones now passes with
-W error::DeprecationWarning.
@github-actions github-actions Bot added the release:maintenance Release category managed from the PR title label Nov 13, 2026
@gouyt13
gouyt13 merged commit 9e2d77d into main Nov 13, 2026
39 checks passed
@gouyt13
gouyt13 deleted the test/214-migrate-remaining-files branch November 13, 2026 05:27
jay23606 pushed a commit to jay23606/RaBitQ-Library that referenced this pull request Nov 14, 2026
IvfIndex.set_centroids takes a keyword-only num_threads for rotating the
centroids and building the routing, as train and add do. Only the HNSW
routing graph varies with it; one thread and a fixed seed build a
reproducible graph. The 0.7 build passed its thread count through, but
the 0.8 split into set_centroids and add lost it.

Without the argument, set_centroids used the C++ default, which runs on
every CPU and ignores OMP_NUM_THREADS, for every initializer. None and 0
now select the available CPUs capped by OMP_NUM_THREADS, like every
other default. That is what processes sharing OpenMP runtimes on macOS
rely on.

Tests check that a single-thread set_centroids gives identical files
and that OMP_NUM_THREADS=1 caps the default. The routing tests that
VectorDB-NTU#230 loosened build with explicit thread counts again: the 128-centroid
test is seeded and exact once more, and the parallel test's thread count
applies to the routing build. The migration guide notes that IVF HNSW
routing is no longer single-threaded by default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:maintenance Release category managed from the PR title

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Python tests off the deprecated 0.7 call forms

1 participant