Reuse IVF Coarse-Quantizer Routing Across Index Segments #8965
majin1102
started this conversation in
Lance Table Format
Replies: 1 comment
BenchmarkConfiguration
Query path
ResultsAcross the 24 configurations, reuse-on increased QPS by 3.9%–259.5%, reduced P50 by 4.7%–72.5%, and reduced P95 by 5.3%–73.6%. All requests succeeded. k=10
k=100
Conclusions
These results describe a single-host, six-segment, fully pre-warmed workload. Cold-cache behavior and workloads with a different number of segments require separate measurement. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Add a content-derived coarse-quantizer fingerprint to IVF index segment metadata. When every physical segment of a logical index has the same well-formed fingerprint, rank the IVF centroids once per query and reuse the selected partition IDs and query-to-centroid distances across all segments.
If any segment has a missing, malformed, or different fingerprint, Lance keeps the existing per-segment routing behavior.
This implements the compatibility-based shared routing described in Lance Vector Index: Multi-Segment Final State.
Draft PR: #8966
Motivation
Lance supports both shared and independently trained IVF models across physical index segments. This proposal does not suggest that segments should share a coarse quantizer, nor does it change the independently trained path.
The optimization applies only when multiple segments intentionally use the same ordered IVF centroids—for example, when distributed workers horizontally index a static or batch-built dataset using one globally trained model. In this topology, the segments are physical shards of one logical IVF index, but a query currently runs
find_partitionsindependently for every segment:For these segments,
find_partitionsreceives identical inputs and returns identical partition IDs and centroid distances. Repeating it once per segment performs identical work. Segments with different coarse quantizers continue to rank and search their partitions independently.The proposed path is:
Only coarse routing is shared. Each segment still searches its own inverted lists before the existing global top-k merge.
Design
The fingerprint is a 32-byte SHA-256 digest over the
lance.coarse_quantizer.v1domain separator, distance metric, centroid count, vector dimension, centroid scalar type, and ordered centroid values in canonical little-endian form. Centroid order is included because partition IDs are positions in that array. The within-partition codec is excluded because it does not affect routing.Lance derives the fingerprint from the final effective
IvfModel, after training, conversion, and partition adjustment. This applies to ordinary, distributed, independently trained, appended, retrained, rebalanced, and merged segments. Operations that preserve the routing model preserve its identity. A writer that cannot reliably describe its final routing state omits the field, causing queries to use the existing path.For a query over two or more segments, Lance compares their fingerprints. If all are equal and well-formed, it opens one representative segment, normalizes the query, calls
find_partitionsonce, and fans out the result. Otherwise it uses the existing path. The first implementation is all-or-nothing and does not group matching subsets within a mixed set of segments.Format change
Add one optional field to
VectorIndexDetails:The persisted fingerprint establishes a routing-compatibility contract between index writers and readers. Lance SDKs and other execution engines can determine from segment metadata, before fan-out, whether all segments use the same ordered coarse model. They can then load the centroid list from one representative segment, rank it once, and reuse the routing result. A reader could instead load and compare the centroids from every segment, but that adds noticeable overhead for cold object-store and short-lived workloads and requires each engine to implement the same discovery logic.
The field always describes the final effective routing model:
As a result, segments with the same final routing model receive the same fingerprint regardless of how they were built.
The field is an optimization hint with fail-closed semantics:
No dataset migration or reader/writer feature flag is required because the field does not affect index readability or query semantics.
Benchmark plan
The benchmark evaluates routing reuse within a shared-model topology. It does not compare shared-model indexing with independently trained segment models.
The benchmark isolates coarse-routing reuse from index construction and storage effects. Two Lance branches are created from the same LAION 100M dataset version and indexed with identical fragment groups, six physical segments, 24,414 IVF centroids, and a shared 5-bit RaBitQ model. The only A/B difference is whether the segments carry the coarse-quantizer fingerprint.
Before measuring performance, query-plan metrics verify that the baseline calls
find_partitionsonce per segment while the optimized path calls it once and reuses the result for the other five segments. They also verify that no payloadLanceReadis introduced.Both indexes are pre-warmed into the index cache before timing. Timed queries return only
_rowidand_distanceand coverk={10,100},nprobes={16,64,256,1024}, and request concurrency{1,8,16}. Recall is calculated separately, outside the timed interval, from the actual ANN results for a fixed query set. Each configuration is repeated three times with alternating A/B order.The benchmark reports QPS, P50/P95/P99 latency, Recall@k, errors, and query-plan routing counters. Detailed results will be posted as a follow-up in this Discussion.
Implementation summary
The draft implementation adds the optional metadata field, fingerprint generation and lifecycle handling, fail-closed validation, rank-once/fan-out execution, and query-plan counters for routing calls and reused segments.
The execution pattern is similar to Faiss
IndexShardsIVF, but Lance needs a persisted identity because its segments are independently stored and versioned.All reactions