Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class IVFPQBuildCagraConfig:
# to use as little GPU memory for the database as possible.
conservative_memory_allocation: bool = True

force_random_rotation: bool = False

@staticmethod
def _validate_params(params: Dict[str, Any]) -> None:
"""
Expand Down Expand Up @@ -120,6 +122,7 @@ def to_faiss_config(self) -> faiss.IVFPQBuildCagraConfig:
config.pq_dim = self.pq_dim
config.n_lists = self.n_lists
config.conservative_memory_allocation = self.conservative_memory_allocation
config.force_random_rotation = self.force_random_rotation
return config

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def custom_params(self) -> Dict[str, Any]:
"pq_bits": 6,
"pq_dim": 16,
"conservative_memory_allocation": False,
"force_random_rotation": True,
}

def test_default_initialization(self, default_config):
Expand All @@ -36,6 +37,7 @@ def test_default_initialization(self, default_config):
assert default_config.pq_bits == 8
assert default_config.pq_dim == 0
assert default_config.conservative_memory_allocation is True
assert default_config.force_random_rotation is False

def test_custom_initialization(self, custom_params):
config = IVFPQBuildCagraConfig(**custom_params)
Expand Down Expand Up @@ -97,6 +99,7 @@ def test_to_faiss_config(self, custom_params):
config.conservative_memory_allocation
== custom_params["conservative_memory_allocation"]
)
assert config.force_random_rotation == custom_params["force_random_rotation"]

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