Skip to content

Bumping up Faiss to have reusing memory optimization. #110

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base_image/faiss
Submodule faiss updated 68 files
+0 −19 .github/workflows/build-release.yml
+0 −18 .github/workflows/nightly.yml
+123 −0 CHANGELOG.md
+1 −1 CMakeLists.txt
+5 −5 INSTALL.md
+1 −1 c_api/Index_c.cpp
+8 −8 contrib/torch_utils.py
+0 −3 faiss/AutoTune.cpp
+5 −7 faiss/Index.h
+0 −2 faiss/Index2Layer.cpp
+0 −25 faiss/IndexAdditiveQuantizer.cpp
+0 −10 faiss/IndexAdditiveQuantizer.h
+4 −7 faiss/IndexBinary.h
+0 −15 faiss/IndexBinaryFlat.cpp
+0 −9 faiss/IndexBinaryFlat.h
+0 −20 faiss/IndexBinaryHNSW.cpp
+0 −10 faiss/IndexBinaryHNSW.h
+0 −1 faiss/IndexBinaryHash.cpp
+0 −15 faiss/IndexFastScan.cpp
+0 −9 faiss/IndexFastScan.h
+0 −27 faiss/IndexFlat.cpp
+0 −17 faiss/IndexFlat.h
+0 −15 faiss/IndexFlatCodes.cpp
+0 −9 faiss/IndexFlatCodes.h
+0 −49 faiss/IndexHNSW.cpp
+0 −28 faiss/IndexHNSW.h
+22 −22 faiss/IndexIDMap.cpp
+5 −5 faiss/IndexIDMap.h
+0 −27 faiss/IndexIVF.cpp
+0 −15 faiss/IndexIVF.h
+0 −15 faiss/IndexIVFFlat.cpp
+0 −6 faiss/IndexIVFFlat.h
+0 −19 faiss/IndexNNDescent.cpp
+1 −10 faiss/IndexNNDescent.h
+0 −59 faiss/IndexPQ.cpp
+0 −28 faiss/IndexPQ.h
+0 −22 faiss/IndexPreTransform.cpp
+0 −10 faiss/IndexPreTransform.h
+0 −18 faiss/IndexScalarQuantizer.cpp
+0 −9 faiss/IndexScalarQuantizer.h
+2 −1 faiss/MetricType.h
+0 −3 faiss/clone_index.cpp
+1 −1 faiss/gpu/GpuCloner.cpp
+35 −34 faiss/gpu/GpuIndex.cu
+13 −13 faiss/gpu/GpuIndex.h
+0 −33 faiss/gpu/GpuIndexBinaryCagra.cu
+0 −10 faiss/gpu/GpuIndexBinaryCagra.h
+0 −15 faiss/gpu/GpuIndexBinaryFlat.cu
+0 −9 faiss/gpu/GpuIndexBinaryFlat.h
+27 −17 faiss/gpu/GpuIndexCagra.cu
+7 −5 faiss/gpu/GpuIndexCagra.h
+0 −27 faiss/gpu/GpuIndexFlat.cu
+0 −15 faiss/gpu/GpuIndexFlat.h
+0 −19 faiss/gpu/GpuIndexIVF.cu
+0 −14 faiss/gpu/GpuIndexIVF.h
+0 −4 faiss/gpu/GpuIndexIVFFlat.cu
+0 −1 faiss/gpu/GpuIndexIVFFlat.h
+0 −4 faiss/gpu/GpuIndexIVFPQ.cu
+0 −1 faiss/gpu/GpuIndexIVFPQ.h
+0 −8 faiss/gpu/GpuIndexIVFScalarQuantizer.cu
+0 −1 faiss/gpu/GpuIndexIVFScalarQuantizer.h
+7 −7 faiss/gpu/test/TestGpuIndexCagra.cu
+6 −24 faiss/impl/RaBitQuantizer.cpp
+0 −3 faiss/index_io.h
+4 −4 faiss/python/class_wrappers.py
+1 −1 faiss/python/loader.py
+1 −1 faiss/python/setup.py
+539 −0 faiss/utils/rabitq_simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ def _do_convert_gpu_to_cpu_binary_index(
):
try:
# Convert GPU binary index to CPU binary index
cpu_index = faiss.index_binary_gpu_to_cpu(
faiss_gpu_build_index_output.gpu_index
)

# Configure CPU Index parameters
cpu_index = faiss.IndexBinaryHNSWCagra()
cpu_index.hnsw.efConstruction = self.ef_construction
cpu_index.hnsw.efSearch = self.ef_search
cpu_index.base_level_only = self.base_level_only

# Convert GPU binary index to CPU binary index
faiss_gpu_build_index_output.gpu_index.copyTo(cpu_index)

# Remove reference of GPU Index from the IndexBinaryIDMap
faiss_gpu_build_index_output.index_id_map.index = None

Expand Down
21 changes: 19 additions & 2 deletions test_remote_vector_index_builder/test_core/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def is_deleted(self):

def copyTo(self, cpu_index):
"""Mock implementation of copyTo method"""
if not isinstance(cpu_index, MockIndexBinaryHNSW):
raise TypeError("Target must be IndexBinaryHNSW")
if not isinstance(cpu_index, MockIndexBinaryHNSWCagra):
raise TypeError("Target must be MockIndexBinaryHNSWCagra")
# Simulate copying data to CPU index
return True

Expand Down Expand Up @@ -160,6 +160,22 @@ def is_deleted(self):
return _deletion_tracker.is_deleted(self.id)


class MockIndexBinaryHNSWCagra(Mock):
"""Mock for IndexBinaryHNSWCagra"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.hnsw = Mock()
self.base_level_only = False

def __del__(self):
_deletion_tracker.mark_deleted(self.id)

@property
def is_deleted(self):
return _deletion_tracker.is_deleted(self.id)


class MockIndexBinaryHNSW(Mock):
"""Mock for faiss.IndexBinaryHNSW"""

Expand Down Expand Up @@ -218,6 +234,7 @@ def __init__(self):
self.StandardGpuResources = Mock()
self.GpuIndexCagra = MockGpuIndexCagra
self.GpuIndexBinaryCagra = MockGpuIndexBinaryCagra
self.IndexBinaryHNSWCagra = MockIndexBinaryHNSWCagra
self.IndexIDMap = MockIndexIDMap
self.IndexBinaryIDMap = MockIndexBinaryIDMap
self.IndexHNSWCagra = MockIndexHNSWCagra
Expand Down