diff --git a/base_image/faiss b/base_image/faiss index 2929bf4..f9ccd58 160000 --- a/base_image/faiss +++ b/base_image/faiss @@ -1 +1 @@ -Subproject commit 2929bf471bcfbc161e6e97356d33582af29a6c05 +Subproject commit f9ccd582f9a9b8400428625d1ff3217ae83422b9 diff --git a/remote_vector_index_builder/core/common/models/index_builder/faiss/faiss_index_hnsw_cagra_builder.py b/remote_vector_index_builder/core/common/models/index_builder/faiss/faiss_index_hnsw_cagra_builder.py index fb5c98b..cb3c69d 100755 --- a/remote_vector_index_builder/core/common/models/index_builder/faiss/faiss_index_hnsw_cagra_builder.py +++ b/remote_vector_index_builder/core/common/models/index_builder/faiss/faiss_index_hnsw_cagra_builder.py @@ -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 diff --git a/test_remote_vector_index_builder/test_core/conftest.py b/test_remote_vector_index_builder/test_core/conftest.py index cdf26e5..4cc32f8 100644 --- a/test_remote_vector_index_builder/test_core/conftest.py +++ b/test_remote_vector_index_builder/test_core/conftest.py @@ -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 @@ -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""" @@ -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