-
Notifications
You must be signed in to change notification settings - Fork 123
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
Add changes for AVX-512 support in k-NN. #2110
Add changes for AVX-512 support in k-NN. #2110
Conversation
…intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
…ankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
…by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
…el.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
Benchmark was run using opensearch-benchmark with cohere dataset(768 dimensions). Her are some configuration details for search: A forcemerge to reduce the number of max_num_segments to 1 is executed via the API before the seach. The opensearch cluster was deployed with 2 data nodes (r7i.2xlarges), 1 replica and 4 shards. |
@assanedi Can you also pls add other configuration details like the indexing clients, query clients, ef_construction, ef_search, etc |
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.
LGTM! Thanks @akashsha1 @assanedi
@assanedi Isn't the max_num_segments was 1 during forcemerge ? |
Yes I run the forcemerge API, here is the results of it: |
Yes, but in the configuration you mentioned it as 10 instead of 1 for |
For FP32 we don’t need to make any changes in Faiss as they are using auto-vectorization to achieve the optimization with AVX512. But, for Scalar Quantization Intel have raised a PR to Faiss which is under review |
I updated the configuration details |
|
||
``` | ||
# While building OpenSearch k-NN | ||
./gradlew build -Dsimd.enabled=true | ||
./gradlew build -Davx2.enabled=true -Davx512.enabled=true |
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.
Shouldnt these be mutually exclusive?
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.
Ideally we want simd (avx2, avx512 - highest of whichever is present) to be enabled by default. The order of checks would be:
if (AVX512 enabled and present) { use avx512 }
else if (AVX2 enabled and present) { use avx2 }
else { use generic version }
by making it mutually exclusive, the intermediate step cannot be achieved.
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.
I think Jack's point is to update it as something like this ./gradlew build -Davx2.enabled=false -Davx512.enabled=true
as we can't use both of them at the same time
@@ -499,6 +512,22 @@ public static boolean isFaissAVX2Disabled() { | |||
} | |||
} | |||
|
|||
public static boolean isFaissAVX512Disabled() { | |||
try { | |||
return KNNSettings.state().getSettingValue(KNNSettings.KNN_FAISS_AVX512_DISABLED); |
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.
Can we do proper null checks here? In general, I think its best to avoid catching all exceptions.
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.
Looks like java boolean cannot be null. So null check won't be possible.
Your second point on exceptions is valid, and this code shouldn't throw exceptions as a default value is set. I've removed the try/catch block.
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.
@akashsha1 as users will manually set this setting in opensearch.yml, there is a chance of getting null. To avoid it shall we change it to
return Booleans.parseBoolean(KNNSettings.state().getSettingValue(KNNSettings.KNN_FAISS_AVX512_DISABLED).toString(), false);
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.
Booleans.parseBoolean
will do the null validation and if it is null, it will return the default value
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.
spoke with Naveen on slack, and updated to
return Booleans.parseBoolean(KNNSettings.state().getSettingValue(KNNSettings.KNN_FAISS_AVX512_DISABLED).toString(), KNN_DEFAULT_FAISS_AVX512_DISABLED_VALUE);
…intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
…aran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
…aran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
…ntel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
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.
LGTM thanks
5423cc1
into
opensearch-project:main
* changes for AVX-512. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * add cpu detection logic to security workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * add cpu detection logic to backward compat test workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * fix bwc workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * address PR feedback. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * fix a bug in KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * fix a bug in KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * update KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> --------- Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> (cherry picked from commit 5423cc1)
* changes for AVX-512. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * add cpu detection logic to security workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * add cpu detection logic to backward compat test workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * fix bwc workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * address PR feedback. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * fix a bug in KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * fix a bug in KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> * update KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> --------- Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> (cherry picked from commit 5423cc1) Signed-off-by: Ryan Bogan <rbogan@amazon.com>
* changes for AVX-512. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> * add cpu detection logic to security workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> * add cpu detection logic to backward compat test workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> * fix bwc workflow. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> * address PR feedback. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> * fix a bug in KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> * fix a bug in KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> * update KNNSettings. Signed-off by: Akash Shankaran <akash.shankaran@intel.com> --------- (cherry picked from commit 5423cc1) Signed-off-by: Akash Shankaran <akash.shankaran@intel.com> Signed-off-by: Ryan Bogan <rbogan@amazon.com> Co-authored-by: akashsha1 <113050768+akashsha1@users.noreply.github.com>
Description
This change adds support to speed up vector search and indexing in faiss using AVX512 hardware accelerator.
Related Issues
Resolves #2056
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.