Skip to content

[MOD-14953] Add calcDistanceForQuery to IndexCalculatorInterface - #1

Merged
xiangze-arm merged 2 commits into
sq8_newfrom
calculator_api
Jul 14, 2026
Merged

[MOD-14953] Add calcDistanceForQuery to IndexCalculatorInterface#1
xiangze-arm merged 2 commits into
sq8_newfrom
calculator_api

Conversation

@xiangze-arm

@xiangze-arm xiangze-arm commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

This PR adds a new calcDistanceForQuery API in IndexCalculatorInterface that lets us separate distance calculation of a query and a candidate from distance calculation of two candidates.

It enables distance compute of asymmetric distances (FP32/FP16 query vs. SQ8 candidate) alongside symmetric distances(SQ8 candidate vs. SQ8 candidate).

Which issues this PR fixes

  1. [MOD-14953]

Main objects this PR modified

  1. IndexCalculatorInterface — Add calcDistanceForQuery API
  2. DistanceCalculatorCommon — Add common implementation
  3. HNSWIndex classes — Change API from calcDistance to calcDistanceForQuery when it is used for query distance calculation
  4. VecSimIndexAbstract class — Add calcDistanceForQuery API for VecSimIndexAbstract class
  5. Tests — Add component test

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Add calcDistanceForQuery() API and use it in HNSW index

@dor-forer dor-forer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job, looks good overall.

Comment thread src/VecSim/spaces/computer/calculator.h Outdated
Comment thread tests/unit/test_components.cpp Outdated
@xiangze-arm
xiangze-arm merged commit ed1df68 into sq8_new Jul 14, 2026
xiangze-arm pushed a commit that referenced this pull request Jul 29, 2026
…isAI#999)

* [MOD-14953] Add calcDistanceForQuery to IndexCalculatorInterface (#1)

* IndexCalculatorInterface change

Add calcDistanceForQuery() API and use it in HNSW index

* Improve tests

(cherry picked from commit ed1df68)

* Format ARM copyright headers

* Remove ARM copyright headers from modified files

* Add context-aware distance dispatch
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.

2 participants