Skip to content

test: cover Bits1_5 in TurboQuant test matrices - #10448

Merged
timvisee merged 1 commit into
qdrant:devfrom
edubraqd:pr/tq-bits15-test-coverage
Sep 3, 2026
Merged

timvisee merged 1 commit into
qdrant:devfrom
edubraqd:pr/tq-bits15-test-coverage

Conversation

@edubraqd

@edubraqd edubraqd commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Nine bit-width matrices in lib/quantization/src/turboquant/quantization.rs omit TQBits::Bits1_5, so that variant is never exercised by them.

This is the same enumeration gap #10390 closed for quantize_output_byte_length: the quantized_size double-padding bug was invisible because the one test that would have caught it did not list the affected variant. The rest of the module still has that gap, while score_precomputed_batch_matches_single already enumerates Bits1_5 — so the inconsistency sits inside a single file.

Test-only change; no production code is touched.

Changes

Bits1_5 added to the seven matrices where it applies:

  • quantize_extreme_values
  • quantize_deterministic
  • quantize_zero_vector
  • quantize_non_power_of_two_dims
  • pack_unpack_vector_roundtrip
  • pack_unpack_vector_uniform_indices
  • score_precomputed_dispatches_all_bit_widths — the name already claims to cover all bit widths

The two Unpadded rotation tests cannot take it, and now say so:

  • unpadded_rotation_keeps_padding_zero and unpadded_rotation_matches_padded_for_padding_free_dims both build quantizers with TQRotation::Unpadded, and TurboQuantizer::new asserts Bits1_5 requires TQRotation::Padded — Bits1_5 rotates into its x1.5 padding, so an unpadded rotation would leave half the codes carrying nothing. Adding it there panics; each list now carries a one-line comment naming the invariant, so the omission reads as deliberate.
  • unpadded_rotation_matches_padded_for_padding_free_dims also claimed multiples of 8 are padding-free "for every supported bit width". That stopped being true when Bits1_5 was added — padded_dim(8) is 16 — so the comment now names the bit widths it actually covers.

Left alone as out of scope: higher_bits_reduce_error asserts the ordering MAE(Bits4) <= MAE(Bits2) <= MAE(Bits1). Placing Bits1_5 in that chain is an accuracy claim that deserves its own justification rather than being folded into a coverage change.

Verification

Run on stable 1.98.0, the toolchain .github/workflows/rust.yml uses.

command result
cargo test -p quantization --lib turboquant 90 passed, 0 failed, 18 filtered out
cargo +nightly fmt --all -- --check clean
cargo clippy -p quantization --all-features --all-targets clean

Before the change the same filter reports 89 tests; the extra one is the new score_precomputed_dispatches_all_bit_widths::bits1_5 case.

AI contribution

Prepared with Claude Code: it audited the bit-width matrices in the module, made the edits, and ran the commands above.

The first attempt added Bits1_5 to unpadded_rotation_keeps_padding_zero as well; the test run caught the Bits1_5 requires TQRotation::Padded assertion in TurboQuantizer::new, which is what established that both Unpadded tests must keep their current lists. The scope call on higher_bits_reduce_error was made against TQBits::bit_size and the centroid tables.

All Submissions:

  • My PR targets the dev branch (not master) and my branch was created from dev.
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Nine bit-width matrices in `turboquant::quantization` omitted
`TQBits::Bits1_5`, so the variant went unexercised there. This is the gap
qdrant#10390 closed for `quantize_output_byte_length`, where a `quantized_size`
double-padding bug had slipped through a hardcoded [Bits1, Bits2, Bits4]
list.

Add `Bits1_5` to the seven matrices that accept it, including the rstest
cases of `score_precomputed_dispatches_all_bit_widths`, whose name already
claims to cover every bit width.

The two `Unpadded` rotation tests keep their lists: `TurboQuantizer::new`
asserts "Bits1_5 requires TQRotation::Padded", since `Bits1_5` rotates
into its x1.5 padding and an unpadded rotation would leave half the codes
carrying nothing. Each list now names that invariant, so the omission
reads as deliberate rather than as the same oversight.
`unpadded_rotation_matches_padded_for_padding_free_dims` also claimed
multiples of 8 are padding-free "for every supported bit width", which
`Bits1_5` falsified: `padded_dim(8)` is 16.

Co-Authored-By: Claude Opus 5 <[email protected]>
@qdrant qdrant deleted a comment from coderabbitai Bot Sep 3, 2026

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@timvisee
timvisee merged commit c2137f9 into qdrant:dev Sep 3, 2026
17 checks passed
timvisee pushed a commit that referenced this pull request Sep 3, 2026
Nine bit-width matrices in `turboquant::quantization` omitted
`TQBits::Bits1_5`, so the variant went unexercised there. This is the gap
#10390 closed for `quantize_output_byte_length`, where a `quantized_size`
double-padding bug had slipped through a hardcoded [Bits1, Bits2, Bits4]
list.

Add `Bits1_5` to the seven matrices that accept it, including the rstest
cases of `score_precomputed_dispatches_all_bit_widths`, whose name already
claims to cover every bit width.

The two `Unpadded` rotation tests keep their lists: `TurboQuantizer::new`
asserts "Bits1_5 requires TQRotation::Padded", since `Bits1_5` rotates
into its x1.5 padding and an unpadded rotation would leave half the codes
carrying nothing. Each list now names that invariant, so the omission
reads as deliberate rather than as the same oversight.
`unpadded_rotation_matches_padded_for_padding_free_dims` also claimed
multiples of 8 are padding-free "for every supported bit width", which
`Bits1_5` falsified: `padded_dim(8)` is 16.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants