-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector efficient math operations for KNN distance functions #617
Comments
Where would we want to configure which distance function to use? Index level options? |
@dblock this will be applicable to all https://opensearch.org/docs/latest/search-plugins/knn/knn-score-script/ functions and will not be part of index options. This will be optimization to our existing vector calculations for bruteforce/exact knn search |
Looks like we need OpenSearch core to move to open jdk 19 to use |
Linking here for visibility: This is also implemented in Elasticsearch and dropped latencies by at least 50% in my case. |
Addressed in #1699 |
Is your feature request related to a problem? Please describe.
Exact-KNN distance functions use sub-optimal vector math operations. This can contribute to extra time on high vector dimension distance compute.
Describe the solution you'd like
Do you think it is possible to use Vector API for math operations in the distance functions?
For example, the following cosine similarity that iterates over each element in both vectors to multiply numbers:
k-NN/src/main/java/org/opensearch/knn/plugin/script/KNNScoringUtil.java
Line 96 in 120c4ce
could apply vector optimal fused multiply-add instead.
If for the usage of Java Vector API, supported java version is a concern, it could also start with
Math.fma()
.Describe alternatives you've considered
ANN would be an option if pre-filtering supported.
Additional context
Much appreciate OpenSearch work on KNN, as it gets bigger demand with ML to relay on vector supporting DBs on distributed computations.
The text was updated successfully, but these errors were encountered: