Repository navigation
Description
Problem
Since 0.8.2 the three index classes share one workflow (construct, add, search), but some
names and defaults still differ between them, and two search conventions hide mistakes:
max_elementsis documented as one "logical record capacity" on all three classes (the
unified count properties of 0.7.0), but it is an allocated capacity only onHnswIndex. On
IvfIndexandSymqgIndexit always equalsnum_stored_points.- Preallocation is
HnswIndex.resize(max_elements)on one class and
IvfIndex.reserve(cluster_id, num_points)on another. seeddefaults toNone(draw one) onIvfIndexandSymqgIndexand to100on
HnswIndex, which also accepts 64-bit seeds where the other two accept 32-bit seeds.- The fourth positional argument of
searchishigh_accuracyonIvfIndexand
num_threadson the graph indexes, sosearch(queries, k, 64, 8)means different things. nprobe=0andef=0select the default, so a computed0silently becomes
num_clusters / 16ormax(k, 64).IvfIndex(initializer=...)selects what the documentation calls the centroid routing
strategy, whileSymqgIndex(init=...)is an unrelated graph initialization.- The graph indexes call their search breadth
ef. Its construction counterpart is
ef_construction, and the C++ library and the k-means classes call the same setting
ef_search.
0.9 already breaks the Python API (#211, #213), so these are fixed in the same release
instead of in a second breaking release.
Proposal
| # | 0.8 | 0.9 | Spelling valid in both |
|---|---|---|---|
| 1a | IvfIndex.max_elements, SymqgIndex.max_elements |
Removed | num_stored_points |
| 1b | HnswIndex.max_elements |
HnswIndex.capacity |
From the transition release |
| 1c | HnswIndex.resize(max_elements) |
HnswIndex.reserve(num_points): room for at least that many stored points; it only grows |
From the transition release |
| 1d | IvfIndex.reserve(cluster_id, num_points) |
IvfIndex.reserve_cluster(cluster_id, num_points), with the same meaning (the total the cluster can hold) |
From the transition release |
| 2a | HnswIndex(seed=100) by default |
seed=None draws one, as on the other two classes |
Pass seed= |
| 2b | HnswIndex accepts a seed in [0, 2**64 - 1] |
[0, 2**32 - 1], as on the other two classes |
A 32-bit seed |
| 3 | nprobe=0 and ef=0 select the default |
ValueError; None selects the default |
None, or omit the argument |
| 4 | search(queries, k, nprobe, high_accuracy, num_threads) and search(queries, k, ef, num_threads) accept every option by position |
Only the breadth stays positional: search(queries, k, nprobe=None, *, high_accuracy=None, num_threads=None) and search(queries, k, ef_search=None, *, num_threads=None) |
Keywords |
| 5 | IvfIndex(initializer=...) and the initializer property |
IvfIndex(routing=...) and a routing property, with the same values; the property keeps reporting the resolved strategy, never 'auto' |
From the transition release |
| 6 | search(queries, k, ef=...) on HnswIndex and SymqgIndex |
search(queries, k, ef_search=...), the name C++ and the k-means classes already use |
By position; ef_search= from the transition release |
Details:
- Row 1 retires
max_elementsfrom the count properties.num_points <= num_stored_points
stays on all three classes, andnum_stored_points <= capacityonHnswIndex. - Row 2a changes results for code that relied on the fixed default: the rotation, the graph
levels and the trained centroids (cp.seedfollows the index seed). Passseed=, with
num_threads=1, for a reproducible build as today. - Row 3 leaves
num_threads=0meaning "every available CPU", and a breadth belowkis
still raised tok. - Row 6 amends the naming contract in
docs/development.md, which lists Python'sefamong
the spellings to retain. repr()printscapacity=androuting=where it printsmax_elements=and
initializer=today.
Transition
The next 0.8.x release accepts both spellings: it adds capacity, HnswIndex.reserve,
reserve_cluster, routing and ef_search, and raises DeprecationWarning for the 0.8
forms of rows 1, 2b, 3, 4, 5 and 6. 0.9 removes those forms, and each then fails with a plain TypeError,
AttributeError or ValueError, not a silent reinterpretation. Row 2a gets no warning: one
on every HnswIndex() without a seed would reach mostly users who need no change, so it is
announced in the release notes only.
The migration guide gets a
"0.8 to 0.9" section with these rows, and its 0.7-to-0.8 table stops recommending
initializer= and resize.
Compatibility
Checked against txtai master (5dddded, 2026-11-13):
- Row 3 needs a backend change:
self.backend.search(queries, k, self.setting("efsearch", None) or 0)(src/python/txtai/ann/dense/rabitq.py:133) passes0for "no setting" and
must passNone. - Row 1 needs a test change:
test/python/testann/testdense/testrabitq.py:145asserts
native.max_elements == 100on a loadedIvfIndexand a loadedHnswIndex;
num_stored_pointsworks before and after. - Rows 2, 4, 5 and 6 need none: txtai passes its HNSW seed explicitly (100 by default),
passesnprobeandefby position with nothing after them, does not passinitializer,
and does not callresizeorreserve.
Both changes belong in the txtai release that #213 waits for, and join its gate.
In this repository the renames touch the Python tests, benchmarks/run.py, the samples and
the index documentation: 29 reads of max_elements, 20 resize calls, 10 reserve calls
and 59 ef= keyword arguments outside the 0.7 compatibility tests that #213 deletes.
Open questions
- Does anyone rely on
HnswIndex.resizeshrinking the capacity?reservedoes not shrink. - Should
metricdrop the'innerproduct'spelling, on the index classes and in
rabitqlib.quant, and keep'l2','ip'and'cosine'?
Activity
gouyt13 commentedon Nov 14, 2026
Progress: #239 (open, targets
dev/0.9) implements every row of the proposal in the extension itself and removes the 0.8 forms:capacityandreserveonHnswIndex,reserve_clusterandroutingonIvfIndex,ef_search, keyword-onlyhigh_accuracyandnum_threads,ValueErrorfornprobe=0andef_search=0, and a drawn 32-bit seed forHnswIndex(). The migration guide has the "From 0.8 to 0.9" section.On the open questions:
HnswIndex.reservedoes not shrink, as proposed. Shrinking remains available in C++ throughHierarchicalNSW::resize.'innerproduct'spelling ofmetricis still undecided and is not part of feat(python)!: remove the 0.7 and 0.8 forms and expose the 0.9 names natively #239.The renames need no further contribution. This issue stays open until 0.9 is released.
gouyt13 commentedon Nov 19, 2026
Update: #239, listed as open in the progress comment above, was merged into
dev/0.9on 2026-11-14 (3685e81). This issue stays open until 0.9 is released.feat(python): accept the 0.9 names and deprecate the 0.8 spellings
gouyt13 commentedon Nov 23, 2026
Released in 0.9.0: the 0.8 spellings that 0.8.5 deprecated are removed, so
capacity,seed,routingandef_searchare the only names. The migration guide lists each change.feat(python)!: remove the 0.7 and 0.8 forms and expose the 0.9 names …
feat(python)!: accept only "ip" as the inner-product metric name