-
Notifications
You must be signed in to change notification settings - Fork 25.3k
optimize OptimizedScalarQuantizer#scalarQuantize when destination can… #129874
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
Conversation
… be an integer array
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
@@ -141,6 +141,36 @@ public QuantizationResult scalarQuantize(float[] vector, byte[] destination, byt | |||
); | |||
} | |||
|
|||
public QuantizationResult scalarQuantizeToInts(float[] vector, int[] destination, byte bits, float[] centroid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are confident in the speed improvements, I would argue that we shouldn't bother with this new method, and simply adjust the APIs.
The on disk format is unchanged, so any older formats should be able to be adjusted that rely on the scalarQuantize
signatures.
...arks/src/main/java/org/elasticsearch/benchmark/vector/OptimizedScalarQuantizerBenchmark.java
Outdated
Show resolved
Hide resolved
I ran on my macbook, there was no significant performance improvement. You saw an improvement on AVX256?
|
I saw the same running locally. I will see if I can speed it up on mac tomorrow. |
Running the benchmarks on AVX512 it shows a nice improvemnet:
Running the benchmarks on AVX2 still shows an improvement, a bit less than in AVX512:
I suspect that the expensive part of the algorithm is the #intoArray call. The biggest the bit size, the less calls we need to make to that method so the faster it goes. For Mac with bit size of 128 we just don't see any real improvement. |
@iverase You still want to make this change? I can review if you are ready? |
I couldn't make it faster in AVX so we are not getting faster there but it is clearly faster in AVX2 and AVX512 so I would say it is a net net win so I am good to push as it is. |
server/src/main/java/org/elasticsearch/index/codec/vectors/OptimizedScalarQuantizer.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its good to me! Being faster on 256/512 is a good win and its no slower on neon-128
# Conflicts: # server/src/main/java/org/elasticsearch/index/codec/vectors/DefaultIVFVectorsWriter.java
…ticsearch into quantizeVectorWithIntervals
optimize OptimizedScalarQuantizer#scalarQuantize when destination can optimize OptimizedScalarQuantizer#scalarQuantize when destination can be an integer array
It is possible to optimize this method if the destination array is an integer array. In that case it is easy to panamize the following loop: