Skip to content

Commit dca4627

Browse files
author
Dooyong Kim
committed
Fix it to use IndexBinaryHNSWCagra explicitly during conversion.
Bump up Faiss from 2929bf4 to f9ccd58. Signed-off-by: Dooyong Kim <kdooyong@amazon.com>
1 parent 142047e commit dca4627

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

base_image/faiss

Submodule faiss updated 68 files

remote_vector_index_builder/core/common/models/index_builder/faiss/faiss_index_hnsw_cagra_builder.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,14 @@ def _do_convert_gpu_to_cpu_binary_index(
9898
):
9999
try:
100100
# Convert GPU binary index to CPU binary index
101-
cpu_index = faiss.index_binary_gpu_to_cpu(
102-
faiss_gpu_build_index_output.gpu_index
103-
)
104-
105-
# Configure CPU Index parameters
101+
cpu_index = faiss.IndexBinaryHNSWCagra()
106102
cpu_index.hnsw.efConstruction = self.ef_construction
107103
cpu_index.hnsw.efSearch = self.ef_search
108104
cpu_index.base_level_only = self.base_level_only
109105

106+
# Convert GPU binary index to CPU binary index
107+
faiss_gpu_build_index_output.gpu_index.copyTo(cpu_index)
108+
110109
# Remove reference of GPU Index from the IndexBinaryIDMap
111110
faiss_gpu_build_index_output.index_id_map.index = None
112111

test_remote_vector_index_builder/test_core/conftest.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def is_deleted(self):
9494

9595
def copyTo(self, cpu_index):
9696
"""Mock implementation of copyTo method"""
97-
if not isinstance(cpu_index, MockIndexBinaryHNSW):
98-
raise TypeError("Target must be IndexBinaryHNSW")
97+
if not isinstance(cpu_index, MockIndexBinaryHNSWCagra):
98+
raise TypeError("Target must be MockIndexBinaryHNSWCagra")
9999
# Simulate copying data to CPU index
100100
return True
101101

@@ -160,6 +160,22 @@ def is_deleted(self):
160160
return _deletion_tracker.is_deleted(self.id)
161161

162162

163+
class MockIndexBinaryHNSWCagra(Mock):
164+
"""Mock for IndexBinaryHNSWCagra"""
165+
166+
def __init__(self, *args, **kwargs):
167+
super().__init__(*args, **kwargs)
168+
self.hnsw = Mock()
169+
self.base_level_only = False
170+
171+
def __del__(self):
172+
_deletion_tracker.mark_deleted(self.id)
173+
174+
@property
175+
def is_deleted(self):
176+
return _deletion_tracker.is_deleted(self.id)
177+
178+
163179
class MockIndexBinaryHNSW(Mock):
164180
"""Mock for faiss.IndexBinaryHNSW"""
165181

@@ -218,6 +234,7 @@ def __init__(self):
218234
self.StandardGpuResources = Mock()
219235
self.GpuIndexCagra = MockGpuIndexCagra
220236
self.GpuIndexBinaryCagra = MockGpuIndexBinaryCagra
237+
self.IndexBinaryHNSWCagra = MockIndexBinaryHNSWCagra
221238
self.IndexIDMap = MockIndexIDMap
222239
self.IndexBinaryIDMap = MockIndexBinaryIDMap
223240
self.IndexHNSWCagra = MockIndexHNSWCagra

0 commit comments

Comments
 (0)