test(index): cover residual computation and ResidualTransform schema paths - #8752
Merged
Xuanwo merged 2 commits intoSep 2, 2026
Merged
Conversation
…paths `vector/residual.rs` had no tests, unlike its siblings `sq/transform.rs`, `flat/transform.rs` and `vector/transform.rs`. It runs on the IVF_PQ build path and computes what PQ actually encodes: each vector minus the centroid of its own partition. Two behaviours had no coverage. `compute_residual` dispatches on the centroid/vector type pair, and the `(Float32, Int8)` arm widens the vectors, so the residual comes back wider than the input. `ResidualTransform` then has to rewrite the field type for that case, or the schema would claim Int8 while the data is Float32. Adds 13 tests: exact subtraction across interleaved partitions, all four dispatch arms, both mismatch errors, and the three transform error paths. Verified non-vacuous: pinning `part_id` to 0, dropping the dimension guard, and forcing the in-place column replacement each fail the matching test (5 of 13).
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The merge from main leaves the residual-test patch unchanged, and the focused coverage still exercises partition-specific subtraction, type dispatch, transform failures, and Int8-to-Float32 schema rewriting on the updated base.
Contributor
Author
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vector/residual.rshad no tests, unlike its siblingssq/transform.rs,flat/transform.rsandvector/transform.rs. It runs on the IVF_PQ build pathand computes what PQ actually encodes: each vector minus the centroid of its
own partition.
Two behaviours had no coverage.
compute_residualdispatches on thecentroid/vector type pair, and the
(Float32, Int8)arm widens the vectors, sothe residual comes back wider than the input.
ResidualTransformthen has torewrite the field type for that case, or the schema would claim Int8 while the
data is Float32.
Adds 13 tests: exact subtraction across interleaved partitions, all four
dispatch arms, both mismatch errors, and the three transform error paths.
Verified non-vacuous: pinning
part_idto 0, dropping the dimension guard, andforcing the in-place column replacement each fail the matching test (5 of 13).