[MOD-14955] Add DistanceCalculatorWithNorm#1002
Conversation
| * | ||
| * @return the distance between the vectors. | ||
| */ | ||
| DistType calcDistance(const void *vector_data1, const void *vector_data2) const { |
There was a problem hiding this comment.
This method calls indexCalculator->calcDistance, restoring the per-distance IndexCalculatorInterface vtable fallback removed by PR #937. DistanceCalculatorWithNorm always returns nullptr for the query kernel, so every visited candidate now takes a virtual call followed by the raw kernel call; existing calculators also pay the new branch. Cache a non-virtual state-aware callback or specialize the normalized dispatch outside the candidate loop, and benchmark against the #937 path before merging
f438a59 to
d37077d
Compare
4deae2b to
a0be70d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a0be70d. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dor-forer-MOD-14952-support-quant-normalization #1002 +/- ##
===================================================================================
+ Coverage 97.11% 97.12% +0.01%
===================================================================================
Files 141 141
Lines 8296 8326 +30
===================================================================================
+ Hits 8057 8087 +30
Misses 239 239 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
* Support norm in QuantPreprocessor * Remove unnecessary allocation and duplicated code (cherry picked from commit 027d551)
d37077d to
7eaa73f
Compare
c559e31 to
5070acb
Compare

Describe the changes in the pull request
This PR is stacked on #1000. Review only the incremental diff against
dor-forer-MOD-14952-support-quant-normalization.Cherry-picks the two commits from ARM-software/VectorSimilarity-for-Arm#3:
493ee7a8andc27401d6.This PR adds
DistanceCalculatorWithNorm, which invokes the selected SQ8 kernel and applies the mean-normalization correction terms needed to recover the distance between the original vectors. The follow-up commit makes metadata reads safe for unaligned storage.The calculator integrates with the construction-time dispatch introduced in #999:
mean_sum_squares.IndexCalculatorInterface::calcDistanceorcalcDistanceForQuery, so it does not restore the per-distance vtable lookup removed by MOD-14916 Devirtualize HNSW / brute-force search hot path #937.Tests cover FP32/FP16, L2/IP, symmetric/asymmetric, zero-mean, randomized-vector, and stateless/stateful dispatch behavior.
Which issues this PR fixes
Main objects this PR modified
DistanceCalculatorWithNormMark if applicable
Validation
make formatmake check-formattest_componentsandtest_hnswtest_components: 40/40 passedtest_hnswexcluding the two external serialization fixtures: 169/169 passedgit diff --check dor-forer-MOD-14952-support-quant-normalization...HEADDistanceDispatchaveraged 2.69 ns/call (no measurable regression within run-to-run noise)