Repository navigation
feat(python): accept the 0.9 k-means names and deprecate the 0.8 spellings - #236
Merged
Merged
Conversation
…lings 0.9 names the k-means parameters like the index parameters (#233). This release accepts both spellings and raises a DeprecationWarning, at the caller's line, for the 0.8 one: - QGKMeans and QGKMeansParameters take nbits (32, 4 or 8), max_degree and ef_construction for quantization_bits (0, 4 or 8), graph_degree and ef_build, as keywords and as attributes of cp. - final_assignment takes 'approximate' or 'exact', also on the cp of IvfIndex and HnswIndex. FinalAssignmentMode members are still accepted, and the attribute still reads back as a member until 0.9. - KMeansIterationStats is the one name of the statistics class. FinalAssignmentMode, QGKMeansIterationStats and RaBitQKMeansIterationStats warn when imported or read from the package, through a module-level __getattr__. The extension keeps the 0.8 names; the new ones live in the Python layer, which 0.9 deletes when the extension is renamed. No 0.8 call changes its result, its exception type or its error message. The statistics class now reports its name as KMeansIterationStats.
This was referenced Nov 14, 2026
Open
TamimEhsan
pushed a commit
to TamimEhsan/khorgosh
that referenced
this pull request
Nov 20, 2026
Bump the version to 0.8.5 in pyproject.toml and CMakeLists.txt, and update the install pins, clone commands and version text in the README, home page, installation, quick start and C++ integration pages. Turn docs/docs/releases/0.8.5.md into the release page: drop "(unreleased)" from the title and the navigation, add the Upgrading section, and correct three statements (search options become keyword-only in 0.9, not now; set_centroids used every CPU for every routing type before VectorDB-NTU#231; the stubs cannot mark the deprecations that depend on a value or the two old statistics names). The Python samples need 0.8.5 since VectorDB-NTU#235 and VectorDB-NTU#236, so their README asks for it. README news gains v0.8.5 and keeps the three most recent entries.
TamimEhsan
pushed a commit
to TamimEhsan/khorgosh
that referenced
this pull request
Nov 28, 2026
main is at v0.8.5 (cf2764f): the 0.9 names with deprecation warnings for the 0.8 spellings (VectorDB-NTU#235, VectorDB-NTU#236) and the 0.8.5 release preparation (VectorDB-NTU#237). Conflicts, resolved by keeping both sides: - docs/docs/index/{hnsw,ivf,qg}.md: the cosine metric and the -1 missing-result ID from dev/0.9, the new names from main. - python_bindings/__init__.py: the FormatError import from dev/0.9 in main's import layout. - python_bindings/__init__.pyi: cosine in the metric lists, routing for initializer. - tests/python/typing/public_api.py: routing= with the cosine metric type. Changes git could not make, because the two sides did not touch the same lines: - The deprecated search overloads from main return int64 IDs, as every search does on dev/0.9; a typing fixture checks it. - The migration guide said three changes come without a warning in 0.9; with int64 IDs, the -1 marker and format 2 that count was wrong.
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.
Summary
0.9 names the k-means parameters like the index parameters. This PR makes the next 0.8 release accept the 0.9 names next to the 0.8 spellings, and raise a
DeprecationWarningfor each 0.8 spelling at the caller's line, so code can move before 0.9 removes the old forms.QGKMeans(quantization_bits=0 | 4 | 8),cp.quantization_bitsnbits=32 | 4 | 8,cp.nbits(32, not 0, keeps raw vectors)graph_degreemax_degreeef_buildef_constructionfinal_assignment=FinalAssignmentMode.Approximate | .Exactfinal_assignment='approximate' | 'exact', also onindex.cpofIvfIndexandHnswIndexQGKMeansIterationStats,RaBitQKMeansIterationStatsKMeansIterationStatsChanges
python_bindings/__init__.pythat feat(python): accept the 0.9 names and deprecate the 0.8 spellings #235 introduced, which 0.9 deletes when the extension itself is renamed. No C++ file changes.TypeError.final_assignment. A string is accepted everywhere a member was. Until 0.9 the attribute still reads back as theFinalAssignmentModemember, and a member is still accepted as a value, without a warning of its own.FinalAssignmentMode,QGKMeansIterationStatsandRaBitQKMeansIterationStatsare served by a module-level__getattr__, which warns where the name is imported or read. They stay in__all__, sofrom rabitqlib import *still provides them and warns three times. They no longer appear indir(rabitqlib).KMeansIterationStats; it still pickles by reference, and pickles that name the old class still load.QGKMeans ef_build and ef_search must be positivenamesef_constructiononly when the caller passed that keyword to the constructor; every other call keeps the message.__init__.pyideclares the new names and marks each 0.8 form@deprecated. mypy 2.4 reports assignments to a deprecated settable attribute but not reads of it (pyright reports both), and PEP 702 cannot mark the two old statistics names, which are plain aliases.clustering.md, the "From 0.8 to 0.9" section of the migration guide, the 0.8.5 release notes and the naming contract indocs/development.mduse the new names; the samples and benchmark scripts do too.Coming in 0.9 without a warning, and listed in the release notes:
cp.final_assignmentreads back as a string.Tests
tests/python/test_compat_09.pyfor the k-means names. The helper that checks a warning now also checks its line number, for the index tests of feat(python): accept the 0.9 names and deprecate the 0.8 spellings #235 as well.nbits=32to raw storage, mapping'exact'to the wrong member, not warning for an old name, a warning one frame too deep, the old attribute using the new encoding, a hard-coded class name, a failing read with no Python caller, a class pickle cannot find, and re-raising an unrelated error each fail at least one test.tests/test_mypy.pychecks that mypy flags the deprecated forms and, in a new test, that it flags none of the forms 0.9 keeps.The other k-means test files still use the 0.8 names. They pass and only warn; moving them belongs with the follow-up that #235 mentioned.
Checks
On Linux x86-64, Xeon Gold 6418H, GCC 14.3, Release, native optimization off; the package was built from this branch and installed, CPython 3.13.
test_compat_09.py,test_train_api.py,test_symqg_api.pyandtest_examples.pyunder-W error::DeprecationWarning: 178 passed.check-python.sh,mkdocs build --strictandgit diff --checkpass. No C++ source changes, so the C++ checks were not run locally.__getattr__and its single warning forfrom rabitqlib import name, property naming, a read with no Python caller, the line-number check) were run as standalone snippets on CPython 3.11, 3.12 and 3.13 with identical results. 3.14, Windows, macOS and ARM are left to CI.__init__, and several tests that could not fail.