Skip to content

Commit b4781e7

Browse files
authored
Fiass Fixes: Add missing faiss param force_random_rotation (#50)
Signed-off-by: Rajvaibhav Rahane <[email protected]>
1 parent a922f0a commit b4781e7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class IVFPQBuildCagraConfig:
5353
# to use as little GPU memory for the database as possible.
5454
conservative_memory_allocation: bool = True
5555

56+
force_random_rotation: bool = False
57+
5658
@staticmethod
5759
def _validate_params(params: Dict[str, Any]) -> None:
5860
"""
@@ -120,6 +122,7 @@ def to_faiss_config(self) -> faiss.IVFPQBuildCagraConfig:
120122
config.pq_dim = self.pq_dim
121123
config.n_lists = self.n_lists
122124
config.conservative_memory_allocation = self.conservative_memory_allocation
125+
config.force_random_rotation = self.force_random_rotation
123126
return config
124127

125128
@classmethod

test_remote_vector_index_builder/test_core/common/models/index_builder/faiss/test_ivf_pq_build_cagra_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def custom_params(self) -> Dict[str, Any]:
2727
"pq_bits": 6,
2828
"pq_dim": 16,
2929
"conservative_memory_allocation": False,
30+
"force_random_rotation": True,
3031
}
3132

3233
def test_default_initialization(self, default_config):
@@ -36,6 +37,7 @@ def test_default_initialization(self, default_config):
3637
assert default_config.pq_bits == 8
3738
assert default_config.pq_dim == 0
3839
assert default_config.conservative_memory_allocation is True
40+
assert default_config.force_random_rotation is False
3941

4042
def test_custom_initialization(self, custom_params):
4143
config = IVFPQBuildCagraConfig(**custom_params)
@@ -97,6 +99,7 @@ def test_to_faiss_config(self, custom_params):
9799
config.conservative_memory_allocation
98100
== custom_params["conservative_memory_allocation"]
99101
)
102+
assert config.force_random_rotation == custom_params["force_random_rotation"]
100103

101104
def test_from_dict_partial(self):
102105
partial_params = {"n_lists": 2048, "kmeans_n_iters": 30}
@@ -107,3 +110,4 @@ def test_from_dict_partial(self):
107110
assert config.pq_bits == 8 # default value
108111
assert config.pq_dim == 0 # default value
109112
assert config.conservative_memory_allocation is True # default value
113+
assert config.force_random_rotation is False

0 commit comments

Comments
 (0)