Skip to content

Refactor quantized scorers for (future) io_uring support - #8791

Merged
generall merged 7 commits into
devfrom
universal-quantized-scorer
May 7, 2026
Merged

generall merged 7 commits into
devfrom
universal-quantized-scorer

Conversation

@ffuugoo

@ffuugoo ffuugoo commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Refactors QuantizedQueryScorer and QuantizedCustomQueryScorer, so that they are ready for future UniversalRead integration.

What this PR does:

  • adds a few methods to "quantized" traits (all with trivial implementations)
    • EncodedVectors::for_each_in_batch
    • EncodedStorage::for_each_in_batch
    • EncodedStorage::score
  • implements score_stored_batch as a trivial composition of for_each_in_batch and score

This PR only implements these for non multi-vector quantized storages, because multi-vector is too special, we'll make it work later... 😅

All Submissions:

  • Contributions should target the dev branch. Did you create your branch 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?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --workspace --all-features command?

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?

Base automatically changed from universal-sparse-scorer to dev April 27, 2026 16:53
@ffuugoo
ffuugoo force-pushed the universal-quantized-scorer branch 4 times, most recently from cedcc6a to 9510d2d Compare April 28, 2026 15:50
@ffuugoo
ffuugoo marked this pull request as ready for review April 28, 2026 16:14
@coderabbitai

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@ffuugoo
ffuugoo force-pushed the universal-quantized-scorer branch from 9510d2d to 4cf89c1 Compare April 29, 2026 09:47
coderabbitai[bot]

This comment was marked as resolved.

@ffuugoo
ffuugoo force-pushed the universal-quantized-scorer branch from 264b5d7 to 6e42ba1 Compare May 5, 2026 21:07
coderabbitai[bot]

This comment was marked as resolved.

@ffuugoo
ffuugoo force-pushed the universal-quantized-scorer branch from 6e42ba1 to bc20660 Compare May 6, 2026 11:49
coderabbitai[bot]

This comment was marked as resolved.

@ffuugoo
ffuugoo force-pushed the universal-quantized-scorer branch from 9b71ab7 to 9ff29cc Compare May 7, 2026 14:26
@ffuugoo
ffuugoo requested review from generall and xzfc May 7, 2026 14:31
...for quantized multi-vector storage types
Comment on lines +384 to +396
fn build_multi<'a, TEncodedVectors: quantization::EncodedVectors + MultivectorOffsets>(
point_id: PointOffsetType,
quantized_data: &'a TEncodedVectors,
hardware_counter: HardwareCounterCell,
) -> Result<Box<dyn RawScorer + 'a>, InternalScorerUnsupported> {
let query_scorer = QuantizedMultiQueryScorer::new_internal(
point_id,
quantized_data,
hardware_counter,
)?;

Ok(Box::new(RawScorerImpl { query_scorer }))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, this is prob the most iffy change in this PR, but it should be fine?

Before, when building raw_internal_scorer, we used QuantizedQueryScorer for both single-vector and multi-vector storage types.

This PR refactored QuantizedQueryScorer to rely on for_each_in_batch, which is not supported by multi-vector storage.

But there is also QuantizedMultiQueryScorer designed specifically for multi-vector storage, that does not rely on for_each_in_batch and otherwise should work the same as "regular" scorer.

Someone, pls help me unpack this. 🥲

@generall
generall merged commit 2a47997 into dev May 7, 2026
15 checks passed
@generall
generall deleted the universal-quantized-scorer branch May 7, 2026 18:20
timvisee pushed a commit that referenced this pull request May 8, 2026
* Add `EncodedStorage::for_each_in_batch` method

* Implement `for_each_in_batch` method for `QuantizedChunkedMmapStorage`

* Add `EncodedVectors::for_each_in_batch` method

* Add `EncodedVectors::score` method

* Implement `score_stored_batch` for `QuantizedQueryScorer` and `Quanti…

* Remove `TElement` and `TMetric` type parameters from `QuantizedMultiQ…

* Use `QuantizedMultiQueryScorer` when building `raw_internal_scorer`...
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