Skip to content

refactor!: rename query factor accessors with the g_ prefix - #201

Merged
gouyt13 merged 3 commits into
mainfrom
refactor/query-factor-accessor-names
Oct 31, 2026
Merged

gouyt13 merged 3 commits into
mainfrom
refactor/query-factor-accessor-names

Conversation

@gouyt13

@gouyt13 gouyt13 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Breaking C++ API change. The query correction-factor accessors now use the g_ prefix, the same as g_add() and g_error(). The old names are removed, with no deprecated aliases.

Old New Classes
k1xsumq() g_k1xsumq() SplitSingleQuery, BatchQuery, SplitBatchQuery, symqg::QuantizedQuery
kbxsumq() g_kbxsumq() SplitSingleQuery, SplitBatchQuery
kbase_sumq() g_kbase_sumq() SplitSingleQuery
  • Matching renames: parameters, locals and private members that hold these values. This includes the optional k1xsumq pointer argument of BatchQuery and the SymphonyQG search entry points, which is now g_k1xsumq. Argument order and types are unchanged.
  • Stable core API v1 (core/api.hpp): unchanged. Only a private member of its prepared query is renamed.
  • No other changes: factor values, numerical behavior, Python API, saved-index formats and dependencies stay the same.
  • Known downstream impact: zvec's tests/core/algorithm/ivf_rabitq/ivf_rabitq_streamer_test.cc calls kbxsumq(). It needs a one-line change to g_kbxsumq() when zvec updates its RaBitQ submodule. A code search finds no zvec use of k1xsumq or kbase_sumq.
  • Release notes: the next release notes should list the rename table above.

The second commit fixes documentation naming found in a review of identifiers in the docs:

  • estimator.md: used F_add, F_rescale, F_error, G_kBxSumq, … which do not exist in the code. It now uses the public names: f_add/f_rescale/f_error/f_add_ex/f_rescale_ex and g_add/g_error/g_kbxsumq/g_k1xsumq.
  • Example variables: estimator.md and quantizer.md now use estimated_distance, error_bound, lower_bound and upper_bound, with _ex for the full-code refinement. They previously mixed lb_dist, est_dist_ex, low_dist_ex and ex_*.
  • Cluster-ID arrays: the IVF page and the IVF/HNSW indexing samples call them cluster_ids instead of gt_type/cids. The unused gt_type alias in sample/cpp/symqg_indexing.cpp is removed.
  • Python IVF example: passes max_elements, the Python parameter name, instead of num_points.
  • docs/development.md: the naming table drops node_id, which no code uses.

The third commit fixes a flaky test that failed in the first ASan/UBSan run of this PR. HnswConstructionTest.ParallelConstructionProducesSearchableIndex required each of the first 16 points to find itself after an 8-thread build. HNSW does not guarantee connectivity: in 500 local 8-thread builds of the same data, about half left 1–2 of the 512 points unreachable, while 1- and 2-thread builds left none. The test now queries every point, checks that each result is a valid ID with a finite distance, and requires at least 99% self-recall (at most 5 misses; the local worst case was 2). That unreachable points appear in about half of the parallel builds may itself be worth tracking separately.

Testing

  • Release build with tests, samples and Python bindings, native optimization OFF (GCC 14): ctest --no-tests=error 441 passed, 1 conditional skip (ThreadCount.BoundParallelForUsesRuntimePlacementAndPropagatesErrors).
    • The build emits 14 GCC warnings (-Warray-bounds, -Wunused-result), all on lines this change does not touch. I did not build an untouched baseline to compare against.
  • ./scripts/check-tidy.sh (clang-tidy 23, full configured set): pass.
  • ./scripts/check-isa-symbols.sh on the portable build: pass, 42 translation units.
  • ./scripts/check-format.sh, git diff --check, and python -m mkdocs build --strict --config-file docs/mkdocs.yml: pass.
  • Updated HNSW test: 500 repeats each with 8 and 16 threads (Release), plus 300 repeats under ASan/UBSan restricted to 2 CPUs: no failures. Full suite after the change: 441 passed.
  • Not run: Python tests. No binding source or Python-visible behavior changed.

Query correction factors now share the g_ prefix already used by g_add()
and g_error():

- k1xsumq() -> g_k1xsumq() on SplitSingleQuery, BatchQuery,
  SplitBatchQuery and symqg::QuantizedQuery
- kbxsumq() -> g_kbxsumq() on SplitSingleQuery and SplitBatchQuery
- kbase_sumq() -> g_kbase_sumq() on SplitSingleQuery

The old names are removed. Parameters, locals and private members that
carry the same value are renamed to match. The stable core API v1 is
unchanged; only a private member of its prepared query is renamed.
Factor values and numerical behavior are unchanged.
The estimator page now names data factors after the f_ layout accessors
and query factors after the g_ query accessors instead of F_/G_ labels
that do not exist in the code. Examples use estimated_distance,
error_bound, lower_bound and upper_bound (with an _ex suffix for the
full-code refinement).

Cluster-ID arrays in the IVF page and indexing samples are named
cluster_ids instead of gt_type/cids, the unused gt_type alias in the
SymphonyQG indexing sample is removed, the Python IVF example passes
max_elements, and the naming table drops node_id, which the code does
not use.
@github-actions github-actions Bot added the release:maintenance Release category managed from the PR title label Oct 31, 2026
HNSW does not guarantee connectivity. In 500 local builds of this test's
data with 8 threads, about half left 1-2 of the 512 points unreachable,
while 1- and 2-thread builds left none. The test required each of the
first 16 points to find itself, so it failed whenever an unreachable
point fell in that range, as in an ASan CI run.

Query every point instead, check that each result is a valid ID with a
finite distance, and require at least 99% self-recall (at most 5 misses;
the local worst case was 2).
@gouyt13
gouyt13 merged commit 8aa44bd into main Oct 31, 2026
49 checks passed
@gouyt13
gouyt13 deleted the refactor/query-factor-accessor-names branch October 31, 2026 17:16
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.

1 participant