feat(python): add shared RaBitQ rotation for distributed IVF_RQ builds#7014
Conversation
|
ACTION NEEDED The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. For details on the error please inspect the "PR Title Check" action. |
a8438c2 to
a5bd8a8
Compare
BubbleCal
left a comment
There was a problem hiding this comment.
Just some naming comments
This is nice and is what on our roadmap! Thanks for the contribution!
| def build_rq_rotation( | ||
| dimension: int, | ||
| num_bits: int = 1, | ||
| rotation_type: str = "fast", |
There was a problem hiding this comment.
let's remove this
rotation_type is an internal param for compatibilty
| *, | ||
| target_partition_size: Optional[int] = None, | ||
| skip_transpose: bool = False, | ||
| rq_rotation: Optional[str] = None, |
| pq_codebook: pa.Array, | ||
| dst_uri: str, | ||
| ): ... | ||
| def build_rq_rotation( |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
873329a to
c010e39
Compare
|
@BubbleCal I believe we are ready. |
|
Fixed linting @BubbleCal. Sorry for the delay |
|
@BubbleCal Apologies for the spam, resolved conflicts, tests are passing and overall it looks OK. I don't know if I can trigger any of the workflows myself so please let me know. |
No worries, it's a limitation that first-time contributor can't trigger the CI Will keep eyes on it |
|
Perfect, unsure if I need to do something specific so I'm just waiting for now |
|
@gstamatakis95 Thanks for the contribution! |
Closes: #7012
What
Distributed
IVF_RQbuilds work in the Rust engine (#6359) but could not be driven from Python because the RaBitQ rotation could not be pinned across workers. Each per-fragment build generated its own random rotation, so segments rotated vectors differently, their binary codes were not comparable, and merging corrupted the index.This adds a way to mint one rotation, broadcast it, and reuse it in every per-fragment build, mirroring how
pq_codebookis injected.Changes
build_rq_rotation(dimension, num_bits=1, rotation_type="fast", dtype="float32")that returns one rotation as a JSON string.rq_rotationparameter tocreate_index_uncommitted, parsed into a new transientRQBuildParams.rotationfield and consumed byRabitQuantizer::build.build()reuses the supplied rotation instead of generating a random one, after validatingnum_bits,code_dim, and the signs length.Notes
Tests
IVF_RQsegments on separate fragments with one shared rotation, merges, commits, and queries.