Add on disk 4x compression with Faiss#2425
Add on disk 4x compression with Faiss#2425naveentatikonda wants to merge 10 commits intoopensearch-project:mainfrom
Conversation
101c94f to
58a66e4
Compare
6721604 to
7739606
Compare
7739606 to
e09cdfd
Compare
| } | ||
| } | ||
|
|
||
| jlong IndexService::initIndexFromTemplate( |
There was a problem hiding this comment.
The only difference between this and initIndex is the index creation call to faiss, can we abstract out the logic and reuse the rest please. you can pass in the pointer returned by faiss to reuse the logic and set the index uniq pointer maybe.
There was a problem hiding this comment.
refactored as discussed and also validated that the index is getting deleted
18c4a8a to
4449fde
Compare
0ea7bc6 to
2bb9e05
Compare
|
Update - After looking at the benchmarks and having a chat with other maintainers of k-NN we want to put this feature on hold from releasing in 2.19. Will run more benchmarking tests and compare them with lucene (with rescoring POC) and then decide if we need to switch the default engine for on_disk 4x compression. |
| if ((quantizationParams.getTypeIdentifier()).equals( | ||
| ScalarQuantizationParams.generateTypeIdentifier(ScalarQuantizationType.EIGHT_BIT) | ||
| )) { |
There was a problem hiding this comment.
to ensure that NPE doesn't come in case quantizationParams.getTypeIdentifier() == null, we should reverse the check.
ScalarQuantizationParams.generateTypeIdentifier(ScalarQuantizationType.EIGHT_BIT).equal(quantizationParams.getTypeIdentifier())
| quantizationState = quantizationService.train(quantizationParams, knnVectorValues, totalLiveDocs, fieldInfo); | ||
| } else { | ||
| initQuantizationStateWriterIfNecessary(); | ||
| quantizationState = quantizationService.train(quantizationParams, knnVectorValues, totalLiveDocs, fieldInfo); | ||
| quantizationStateWriter.writeState(fieldInfo.getFieldNumber(), quantizationState); | ||
| } |
There was a problem hiding this comment.
I think this whole logic can be simplified where we create the QS first and then we just see if writer needs to init and it needs to write the state,.
| return (indexInfo.getQuantizationState() instanceof ByteScalarQuantizationState); | ||
| } | ||
|
|
||
| private byte[] getIndexTemplate(BuildIndexParams indexInfo) { |
There was a problem hiding this comment.
nit pick: make the param final for all the functions
| int dimensions; | ||
|
|
||
| if (quantizationState != null) { | ||
| if (quantizationState != null && !(quantizationState instanceof ByteScalarQuantizationState)) { |
There was a problem hiding this comment.
need java doc on this. This kind of instanceOf check is making me nervous. can we think of something here.
| public QuantizationState train(final TrainingRequest<float[]> trainingRequest, final FieldInfo fieldInfo) throws IOException { | ||
| return null; | ||
| } |
| public QuantizationState train(final TrainingRequest<float[]> trainingRequest, final FieldInfo fieldInfo) throws IOException { | ||
| return null; | ||
| } |
| */ | ||
| QuantizationState train(TrainingRequest<T> trainingRequest) throws IOException; | ||
|
|
||
| QuantizationState train(TrainingRequest<T> trainingRequest, FieldInfo fieldInfo) throws IOException; |
There was a problem hiding this comment.
please add java doc and also why we need this function? I thought we are keeping QF free from fieldInfo and other things.
| import static org.opensearch.knn.common.FieldInfoExtractor.extractVectorDataType; | ||
| import static org.opensearch.knn.index.codec.transfer.OffHeapVectorTransferFactory.getVectorTransfer; | ||
|
|
||
| public class ByteScalarQuantizer implements Quantizer<float[], byte[]> { |
There was a problem hiding this comment.
Please add java doc on all your new classes.
| if (sampledIndices.length == 0) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
should we have some logs here.
2bb9e05 to
e3bfbf1
Compare
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
Signed-off-by: Naveen Tatikonda <[email protected]>
e3bfbf1 to
d86a1b6
Compare
Description
Add on disk 4x compression with Faiss which accepts fp32 vectors as input and dynamically quantizes them into byte sized vectors using the Faiss SQ8 quantizer.
Related Issues
Resolves #1723
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.