MOD-13451 Add pre-computed sum to L2 query blob in QuantPreprocessor #883
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.
Extended the L2 query blob to include both
y_sum(sum of query values) andy_sum_squares(sum of squared query values) to support asymmetric L2 distance computation.Motivation
L2 squared distance is computed as:
Where the inner product with a quantized storage vector is:
The
y_sumterm is required to computeIP(x, y), which in turn is needed for the L2 distance formula. Previously onlyy_sum_squareswas stored in the query blob.Changes
Query blob layout update for L2:
| query_values[dim] | y_sum_squares || query_values[dim] | y_sum | y_sum_squares |Query blob size for L2:
(dim + 1) * sizeof(DataType)(dim + 2) * sizeof(DataType)Code improvements:
sum_fast()andsum_squares_fast()into a singleassign_query_metadata()functionsq8::SUM_QUERYandsq8::SUM_SQUARES_QUERYmetadata indicesFiles Modified
src/VecSim/spaces/computer/preprocessors.hsrc/VecSim/types/sq8.hNotes
| query_values[dim] | y_sum |