Skip to content

Align k-means parameter names with the index API #233

Closed

Description

@gouyt13

Problem

QGKMeans configures the same SymphonyQG graph as SymqgIndex under different names, and
since 0.8 renamed quantization_bits to nbits on the index, one of them also has a
different encoding:

Concept SymqgIndex QGKMeans
Raw or quantized graph storage nbits=32 | 4 | 8 quantization_bits=0 | 4 | 8
Graph degree bound max_degree graph_degree
Construction search breadth ef_construction ef_build

Three more leftovers apply to both QGKMeans and RaBitQKMeans:

  • final_assignment takes a FinalAssignmentMode, the only enum in the public Python API;
    every other choice between named modes is a string (metric='ip', init='pipnn').
  • FinalAssignmentMode.SymphonyQG is a second name for Approximate.
  • RaBitQKMeansIterationStats is an alias of QGKMeansIterationStats, so the statistics of
    a RaBitQKMeans run are QGKMeansIterationStats objects.

Proposal

Python:

0.8 0.9
quantization_bits (0, 4, 8) on QGKMeans and QGKMeansParameters nbits (32, 4, 8)
graph_degree max_degree
ef_build ef_construction
final_assignment=FinalAssignmentMode.Approximate | .Exact, including index.cp.final_assignment on IvfIndex and HnswIndex final_assignment='approximate' | 'exact'; FinalAssignmentMode leaves the package
QGKMeansIterationStats, RaBitQKMeansIterationStats One class, KMeansIterationStats

C++:

  • QGKMeansParameters takes the three field renames, and its quantization_bits = 0
    becomes nbits = 32. RaBitQKMeansParameters has none of these fields and does not change.
  • final_assignment stays a FinalAssignmentMode (enums are the C++ convention, as for
    MetricType); the SymphonyQG enumerator is removed.
  • The aliases qgkmeans::QGKMeansIterationStats and
    rabitqkmeans::RaBitQKMeansIterationStats are removed in favour of the existing
    clustering::KMeansIterationStats.
  • QGAssigner keeps its positional constructor, including quantization_bits with 0 for
    raw storage, the value the graph class itself takes.
  • docs/development.md lists QGKMeansParameters::ef_build and the graph parameter names
    among the spellings to retain; that passage is amended.

Unchanged: ef_search (the index classes take the same name in 0.9, replacing ef: #232),
graph_build_iterations, d, k, seed, niter, and what train returns.

Transition

The next 0.8.x release accepts both forms in Python: the new keyword and attribute names,
strings as well as enum members for final_assignment, and KMeansIterationStats next to
the two old names, with a DeprecationWarning for each old form. 0.9 removes the old forms;
a removed keyword then fails like any unknown keyword. C++ has no transition release: the
renames are listed in the 0.9 release notes.

Compatibility

Breaking for code that passes or sets the renamed parameters, compares against the enum or
imports the two statistics class names, and for tests that match the error messages naming
quantization_bits. Neither known downstream is affected: txtai clusters with scikit-learn
(checked at 5dddded, 2026-11-13), and zvec includes no clustering header (checked at
0c2e67a, 2026-11-13).

Activity

  1. added this to the 0.9 milestone on Nov 13, 2026
  2. added
    enhancement
    python
    on Nov 13, 2026
  3. gouyt13 commented on Nov 14, 2026

    @gouyt13
    MemberAuthor

    Progress: #239 (open, targets dev/0.9) implements the 0.9 side of this issue.

    • Python: QGKMeans and QGKMeansParameters take nbits (32, 4 or 8), max_degree and ef_construction; final_assignment is 'approximate' or 'exact', also on index.cp, and reads back as that string; KMeansIterationStats is the only statistics class name. The 0.8 spellings and FinalAssignmentMode are removed.
    • C++: QGKMeansParameters has the same three field names, FinalAssignmentMode::SymphonyQG and the two statistics aliases are removed, and QGAssigner keeps its constructor.

    One difference from 0.8.5: an invalid nbits is reported by train, like the other parameters, not when it is set.

    Nothing else is planned here, so no further contribution is needed. This issue stays open until 0.9 is released.

  4. gouyt13 commented on Nov 19, 2026

    @gouyt13
    MemberAuthor

    Update: #239, listed as open in the progress comment above, was merged into dev/0.9 on 2026-11-14 (3685e81). This issue stays open until 0.9 is released.

  5. gouyt13 commented on Nov 23, 2026

    @gouyt13
    MemberAuthor

    Released in 0.9.0: the old k-means parameter names are removed in Python, and C++ uses the same names. The migration guide lists each change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpython

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions