Skip to content

fix(index): name the differing field when IVF_RQ segments cannot be merged - #11462

Merged
Xuanwo merged 1 commit into
lance-format:mainfrom
sezruby:fix/rq-merge-mismatch-message
Nov 25, 2026
Merged

Xuanwo merged 1 commit into
lance-format:mainfrom
sezruby:fix/rq-merge-mismatch-message

Conversation

@sezruby

@sezruby sezruby commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Problem

merge_existing_index_segments rejects IVF_RQ segments built without a shared rotation model, but its error does not say why. Each build draws a random rotation unless one is supplied, so segments trained independently differ only in fast_rotation_signs. That field is checked but not printed, so the error shows identical values on both sides:

Distributed RQ merge: structural mismatch across shards; first(code_dim=16, num_bits=1, rotation_type=Fast), current(code_dim=16, num_bits=1, rotation_type=Fast)

query_estimator is also checked without being printed. A matrix rotation that differs fails with RQ rotation matrix mismatch across shards, also without a pointer to the fix.

Change

  • The error names the source shard and each field that differs from the first shard, with both values.
  • When the rotation differs (fast rotation signs or matrix), the error says to build every segment with the same rotation model: RQBuildParams::rotation in Rust, rabitq_model in Python, RQBuildParams.Builder.setModel in Java.
  • The merge rules are unchanged.

Why it matters

Merging is what makes a segment-per-fragment build as fast to query as one index, and this error is where users learn that the segments need a shared rotation.

Batched search (one call with all query vectors), k = 10, nprobes = 16, medians of 5 runs after a warmup. Two runs on an 18-core laptop with 1M × 128-d clustered synthetic vectors in 10 fragments, IVF_RQ 5-bit with 256 partitions. Every arm uses the same IVF centroids and the same rabitq_model:

Index Recall@10 (run 1 / run 2) 1,000 queries 4,000 queries
One index over all fragments 0.787 / 0.780 56 / 62 ms 210 / 230 ms
10 segments, not merged 0.790 / 0.777 150 / 141 ms 503 / 517 ms
10 segments, merged 0.787 / 0.780 58 / 63 ms 233 / 237 ms
  • Unmerged segments are 2.2-2.7× slower. Merged segments are within 1.02-1.11× of one index, and the merge took 0.05-0.06 s.
  • On 10M × 1024-d embeddings on object storage (one 32-core process, IVF_RQ 5-bit, 256 partitions), 10 segments built from shared centroids were 2.6-2.9× slower than one index: 1.08 vs 0.40 s for 1,000 queries and 10.08 vs 3.42 s for 16,000. Merging them failed with the message above, so the single index there was built in one call.
  • Built without a shared model, the same segments now fail with:
Distributed RQ merge: source shard 1 does not match the first shard: fast_rotation_signs differ; segments are mergeable only when every one is built with the same RQ rotation model (`RQBuildParams::rotation`; `rabitq_model` in Python, `RQBuildParams.Builder.setModel` in Java)

Tests

test_merge_ivf_rq_names_mismatched_shard_metadata covers fast rotation signs, a matrix rotation, and num_bits. It asserts the field named in the message and whether the rotation hint is present. All three cases fail on the old messages. The test helper now stores a matrix rotation in a global buffer, as the index writer does.

Validation: cargo test -p lance-index --lib vector::distributed (21 pass), the Python RQ and distributed index tests (45 pass), fmt, and cargo clippy -p lance-index --tests --benches -- -D warnings -A unreachable_code -A dead_code. The two allows only silence aarch64-only warnings in lance-encoding and lance-io, which stop a full local clippy run on Apple Silicon; CI lints on x86.

🤖 Generated with Claude Code

…erged

The distributed RQ merge rejected shards whose query_estimator or
fast_rotation_signs differed but printed only code_dim, num_bits and
rotation_type, so segments trained independently (each with its own
random rotation) failed with identical values on both sides. The error
now names the source shard and each differing field, and when the
rotation differs it points to building every segment with one shared
rotation model.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer bug Something isn't working labels Nov 25, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The merge invariants are preserved, and the recovery hint matches the supported build APIs. All 21 distributed-index tests pass, including the three new mismatch regressions.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026
@Xuanwo
Xuanwo merged commit 28d4752 into lance-format:main Nov 25, 2026
42 checks passed
Xuanwo pushed a commit that referenced this pull request Nov 30, 2026
…rges (#11467)

## What

- `guide/vector_search.md`: new **Batch Queries** section with Python
(2-D `q`), Rust (list-array query) and Java (`Query.Builder.setKeys`)
examples. It covers the `query_index` column, how `limit`/`offset`
apply, and the cases that search each query separately. The list follows
`batch_index_search_supported` in `dataset/scanner/vector.rs`.
- `quickstart/vector-search.md`: the batch paragraph said adaptive
probes use per-query execution. Since #10443 they share partition scans,
except on IVF_RQ. The paragraph now points to the guide for the
remaining cases.
- `guide/distributed_indexing.md`: mergeable IVF-RQ segments need one
shared rotation model (`rabitq_model` from `build_rq_model`, or
`RQBuildParams.Builder.setModel` in Java); the merge error has named
this since #11462. The section also adds the measured query cost of
unmerged segments, from the #11462 benchmark.

## Validation

- Python example run against a local build: `query_index` is the first
column (int32, no nulls), 10 rows per query, and `limit=5` returns 5
rows in total.
- Rust example compiled and run as a temporary example: `query_index` is
the first column, 20 rows for 2 queries.
- The Java example uses the same calls as the batch tests in
`VectorSearchTest`.
- `./clean-full-website.sh && uv run mkdocs build --strict` passes, and
the `#batch-queries` link resolves.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants