Skip to content

Encapsulate quantized and full-precision vector access in composite FloatVectorValues#3271

Draft
VijayanB wants to merge 1 commit into
opensearch-project:mainfrom
VijayanB:refactr-bq
Draft

Encapsulate quantized and full-precision vector access in composite FloatVectorValues#3271
VijayanB wants to merge 1 commit into
opensearch-project:mainfrom
VijayanB:refactr-bq

Conversation

@VijayanB
Copy link
Copy Markdown
Member

Description

Introduce QuantizedFloatVectorValues as an inner class of NativeEngines990KnnVectorsReader,
following the same pattern as Lucene's ScalarQuantizedVectorValues. This composite bundles
full-precision float vectors with quantized byte vectors into a single FloatVectorValues:

  • vectorValue(ord) returns full-precision floats for merge/flush
  • scorer(float[]) quantizes the query and delegates to quantized byte values for search
  • rescorer(float[]) delegates to raw float values for full-fidelity rescoring

For ADC fields, scorer(float[]) delegates directly to FaissScorableByteVectorValues which
handles asymmetric float-vs-byte scoring via its FlatVectorsScorer. For non-ADC (Hamming/BQ),
the float query is quantized to bytes using the cached QuantizationState before scoring.

Key changes:

  • NativeEngines990KnnVectorsReader.getFloatVectorValues() returns the composite when quantization is configured, plain float values otherwise
  • Extract getQuantizationState() helper to deduplicate state loading across search() and the composite's scorer()
  • Add scorer(float[]) to FaissScorableByteVectorValues for ADC asymmetric scoring
  • Simplify ExactSearcher by removing manual quantization/ADC transform logic, delegating to the composite's scorer instead
  • Remove shouldRetrieveQuantizedVectors bypass in KNNVectorValuesFactory

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…FloatVectorValues

  Introduce QuantizedFloatVectorValues as an inner class of NativeEngines990KnnVectorsReader,
  following the same pattern as Lucene's ScalarQuantizedVectorValues. This composite bundles
  full-precision float vectors with quantized byte vectors into a single FloatVectorValues:

  - vectorValue(ord) returns full-precision floats for merge/flush
  - scorer(float[]) quantizes the query and delegates to quantized byte values for search
  - rescorer(float[]) delegates to raw float values for full-fidelity rescoring

  For ADC fields, scorer(float[]) delegates directly to FaissScorableByteVectorValues which
  handles asymmetric float-vs-byte scoring via its FlatVectorsScorer. For non-ADC (Hamming/BQ),
  the float query is quantized to bytes using the cached QuantizationState before scoring.

  Key changes:
  - NativeEngines990KnnVectorsReader.getFloatVectorValues() returns the composite when
    quantization is configured, plain float values otherwise
  - Extract getQuantizationState() helper to deduplicate state loading across search() and
    the composite's scorer()
  - Add scorer(float[]) to FaissScorableByteVectorValues for ADC asymmetric scoring
  - Simplify ExactSearcher by removing manual quantization/ADC transform logic, delegating
    to the composite's scorer instead
  - Remove shouldRetrieveQuantizedVectors bypass in KNNVectorValuesFactory

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
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.

1 participant