-
Notifications
You must be signed in to change notification settings - Fork 171
[LuceneOnFaiss Part-8] Added index.knn.memory_optimized_search
index setting.
#2616
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
[LuceneOnFaiss Part-8] Added index.knn.memory_optimized_search
index setting.
#2616
Conversation
d53f941
to
e8b446b
Compare
src/main/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsReader.java
Outdated
Show resolved
Hide resolved
e8b446b
to
4e34f01
Compare
Part-7 #2608 was merged. |
fbd6e65
to
fcef387
Compare
Hi @jmazanec15 , In this revision, I've included a hybrid approach inspired by @shatejas 's suggestion. Previously, I added lazy loading in search because accessing the However, this scenario is rare. In most cases, OpenSearch's internal framework (e.g., With this hybrid approach, we attempt to initialize in the constructor. If Let me know if you have any major concerns. I think this approach not only mitigates potential p99 issues but also avoids the Lucene SPI limitation. |
src/main/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsReader.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsReader.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/memoryoptsearch/faiss/MemoryOptimizedSearchSupportSpec.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/memoryoptsearch/faiss/MemoryOptimizedSearchSupportSpec.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/codec/BasePerFieldKnnVectorsFormat.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/codec/BasePerFieldKnnVectorsFormat.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsFormat.java
Show resolved
Hide resolved
c0dc961
to
822f918
Compare
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 good overall - couple of comments
src/main/java/org/opensearch/knn/index/codec/KNN990Codec/NativeEngines990KnnVectorsReader.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/knn/index/query/KNNQueryBuilderTests.java
Outdated
Show resolved
Hide resolved
822f918
to
6132ada
Compare
Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
6132ada
to
952723d
Compare
Will update in the next PR.
It's being tracked in #2401 (comment)
58fcb37
into
opensearch-project:lucene-on-faiss
…arch-project#2616) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
…arch-project#2616) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
…arch-project#2616) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
…arch-project#2616) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
… FAISS index. (#2630) * Adding basic building blocks for MemoryOptimizedSearch. At the moment, only FAISS is supporing this. (#2581) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added IxMp section loading logic from FAISS index. (#2590) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FaissHNSW and bridge to Lucene HNSW graph. (#2594) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS float flat index. (#2598) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS byte index deserializer - FaissIndexScalarQuantizedFlat (#2604) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Enable memory optimized searching in VectorReader for FAISS engine. (#2608) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS CAGRA index. (#2621) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added index scope setting 'index.knn.memory_optimized_search' (#2616) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Apply monotonic increasing integer encoding to FAISS HNSW and IdMapIndex. (#2609) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Adding byte index, FP16 index decoding. (#2618) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added integration tests for LuceneOnFaiss (#2630) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> --------- Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
… FAISS index. (opensearch-project#2630) * Adding basic building blocks for MemoryOptimizedSearch. At the moment, only FAISS is supporing this. (opensearch-project#2581) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added IxMp section loading logic from FAISS index. (opensearch-project#2590) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FaissHNSW and bridge to Lucene HNSW graph. (opensearch-project#2594) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS float flat index. (opensearch-project#2598) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS byte index deserializer - FaissIndexScalarQuantizedFlat (opensearch-project#2604) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Enable memory optimized searching in VectorReader for FAISS engine. (opensearch-project#2608) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS CAGRA index. (opensearch-project#2621) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added index scope setting 'index.knn.memory_optimized_search' (opensearch-project#2616) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Apply monotonic increasing integer encoding to FAISS HNSW and IdMapIndex. (opensearch-project#2609) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Adding byte index, FP16 index decoding. (opensearch-project#2618) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added integration tests for LuceneOnFaiss (opensearch-project#2630) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> --------- Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
… FAISS index. (opensearch-project#2630) * Adding basic building blocks for MemoryOptimizedSearch. At the moment, only FAISS is supporing this. (opensearch-project#2581) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added IxMp section loading logic from FAISS index. (opensearch-project#2590) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FaissHNSW and bridge to Lucene HNSW graph. (opensearch-project#2594) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS float flat index. (opensearch-project#2598) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS byte index deserializer - FaissIndexScalarQuantizedFlat (opensearch-project#2604) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Enable memory optimized searching in VectorReader for FAISS engine. (opensearch-project#2608) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added FAISS CAGRA index. (opensearch-project#2621) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added index scope setting 'index.knn.memory_optimized_search' (opensearch-project#2616) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Apply monotonic increasing integer encoding to FAISS HNSW and IdMapIndex. (opensearch-project#2609) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Adding byte index, FP16 index decoding. (opensearch-project#2618) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> * Added integration tests for LuceneOnFaiss (opensearch-project#2630) Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]> --------- Signed-off-by: Dooyong Kim <[email protected]> Co-authored-by: Dooyong Kim <[email protected]>
Description
This PR adds
index.knn.memory_optimized_search
index settings.Overall, this brings two major changes listed below along with the new setting definition:
In codec level, it relies on MapperService to retrieve
index.knn.memory_optimized_search
bool flag. Which then be used to determine whether to initialize partial loading on KNN fields.But this is not always working, during recovery MapperService can be null, therefore adding lazy-loading logic in both constructor and search method. For 99%, it will be loaded in the constructor, so it won't affect search p99 latency as by the time the search method is called, MemoryOptimizedSearch should be loaded already.
Branching in KNNQueryBuilder
This PR will make each knn field type decide whether memory-optimized-search is supported or not.
Currently only Float HNSW is supported, therefore any binary HNSW graphs will return
false
to indicate the feature is not supported.If target field in search is supported for memory-optimized-search, control will fallback to Lucene query to proceed vector search. In which, Lucene's HNSW graph searcher will perform KNN search + Radius search on FAISS index.
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
RFC: #2401
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.