Skip to content

feat(python)!: accept only "ip" as the inner-product metric name - #241

Merged
gouyt13 merged 1 commit into
dev/0.9from
feat/drop-innerproduct
Nov 15, 2026
Merged

gouyt13 merged 1 commit into
dev/0.9from
feat/drop-innerproduct

Conversation

@gouyt13

@gouyt13 gouyt13 commented Nov 15, 2026

Copy link
Copy Markdown
Member

Part of #232.

Summary

The index classes and rabitqlib.quant accepted "innerproduct" as a second spelling of "ip", while index.metric and quant.Query.metric always report "ip". 0.9 spells each concept one way, so the shared metric parser (metric_from_string and index_metric_from_string in python_bindings/bindings_common.hpp) drops the alias.

  • metric="innerproduct" raises ValueError with the existing messages:
    • metric must be 'l2', 'ip' or 'cosine' from IvfIndex, HnswIndex and SymqgIndex;
    • metric must be 'l2' or 'ip' from quant.Query, quant.query_terms and quant.code_factors.
  • "ip", "l2" and "cosine" are unchanged. Loaded files store a metric code, not the string, so index.metric of every loaded file is unchanged.
  • The stubs, docstrings, quick start and the clustering sample CLI (sample/python/clustering_cli/ivf.py) drop the alias.

Behaviour change

0.8.5 accepted "innerproduct" without a deprecation warning. The release notes therefore list it under the changes 0.8.5 did not announce. The migration guide adds it to the paragraph of changes that come without a warning, not to the table of 0.8.5 deprecations. txtai passes metric="ip".

rabitqlib.quant is included because it shares the parser and is provisional; #232 names both.

Tests

  • New test_innerproduct_is_no_longer_a_metric_name in tests/python/test_removed_forms.py checks the rejection on the three index classes and on quant.Query, query_terms and code_factors. Against the previous build each of these calls is accepted, so the test fails there.
  • The typing fixture rejects IvfIndex(64, 1, metric="innerproduct"). With the previous stubs, mypy reports the type: ignore on that line as unused.
  • Tests that passed "innerproduct" (test_index_repr.py, test_examples.py) now pass "ip".

Verification

Local, Linux x86-64, Python 3.13, scratch wheel of this commit:

  • pytest: 1178 passed, 18 skipped. 16 of the skips are test_cpp_clustering_examples.py, which needs the C++ example binaries in bin/; the other 2 are the macOS and Linux ARM64 wheel tests.
  • test_editor_support.py, test_mypy.py, test_pyright.py: 18 passed.
  • check-python.sh, check-format.sh, full check-tidy.sh (clang-tidy 23), mkdocs build --strict, git diff --check.

The index classes and rabitqlib.quant accepted "innerproduct" as a second
spelling of "ip"; index.metric and quant.Query.metric always report "ip".
For 0.9, which spells each concept one way (#232), the shared metric
parser drops the alias, so metric="innerproduct" raises ValueError with
the existing messages. 0.8.5 accepted it without a warning, so the release
notes and the migration guide list it with the changes that come without
one.

The stubs, docstrings, quick start and the clustering sample CLI drop the
alias too. Tests that used it now pass "ip"; a new test checks that the
three index classes and quant.Query, query_terms and code_factors reject
it, and the typing fixture checks that mypy and Pyright reject it.
@github-actions github-actions Bot added the release:added Release category managed from the PR title label Nov 15, 2026
@gouyt13
gouyt13 merged commit aec9df4 into dev/0.9 Nov 15, 2026
25 checks passed
@gouyt13
gouyt13 deleted the feat/drop-innerproduct branch November 15, 2026 15:10
@gouyt13 gouyt13 added the release:breaking Breaking change; listed first in release notes (set by hand) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:added Release category managed from the PR title release:breaking Breaking change; listed first in release notes (set by hand)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant