Skip to content

Commit b19e309

Browse files
authored
Merge pull request #1800 from weaviate/uncompressed_quantizer
Add uncompressed quantitizer factory
2 parents c69cfa1 + 0292fa0 commit b19e309

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
WEAVIATE_129: 1.29.9
2626
WEAVIATE_130: 1.30.12
2727
WEAVIATE_131: 1.31.5
28-
WEAVIATE_132: 1.32.0-rc.1-098c594
28+
WEAVIATE_132: 1.32.4-cdf9a3b
2929

3030
jobs:
3131
lint-and-format:

integration/test_collection_config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,3 +1636,22 @@ def test_collection_config_create_with_deprecated_syntax(
16361636
assert config.vectorizer_config is None
16371637
assert config.vector_config is None
16381638
assert config.vectorizer == Vectorizers.NONE
1639+
1640+
1641+
def test_uncompressed_quantitizer(collection_factory: CollectionFactory) -> None:
1642+
dummy = collection_factory("dummy")
1643+
if dummy._connection._weaviate_version.is_lower_than(1, 32, 4):
1644+
pytest.skip("uncompressed is not supported in Weaviate versions lower than 1.32.4")
1645+
1646+
collection = collection_factory(
1647+
vector_index_config=Configure.VectorIndex.hnsw(
1648+
vector_cache_max_objects=5,
1649+
quantizer=Configure.VectorIndex.Quantizer.none(),
1650+
),
1651+
)
1652+
1653+
config = collection.config.get()
1654+
assert config.vector_index_type == VectorIndexType.HNSW
1655+
assert config.vector_index_config is not None
1656+
assert isinstance(config.vector_index_config, _VectorIndexConfigHNSW)
1657+
assert config.vector_index_config.quantizer is None

weaviate/collections/classes/config_vector_index.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def vector_index_type() -> VectorIndexType: ...
8080
def _to_dict(self) -> Dict[str, Any]:
8181
ret_dict = super()._to_dict()
8282
if self.quantizer is not None:
83-
ret_dict[self.quantizer.quantizer_name()] = self.quantizer._to_dict()
83+
if isinstance(self.quantizer, _UncompressedConfigCreate):
84+
ret_dict[self.quantizer.quantizer_name()] = True
85+
else:
86+
ret_dict[self.quantizer.quantizer_name()] = self.quantizer._to_dict()
8487
if self.distance is not None:
8588
ret_dict["distance"] = str(self.distance.value)
8689
if self.multivector is not None and self.multivector.encoding is not None:
@@ -280,6 +283,12 @@ def quantizer_name() -> str:
280283
return "rq"
281284

282285

286+
class _UncompressedConfigCreate(_QuantizerConfigCreate):
287+
@staticmethod
288+
def quantizer_name() -> str:
289+
return "skipDefaultQuantization"
290+
291+
283292
class _PQConfigUpdate(_QuantizerConfigUpdate):
284293
bitCompression: Optional[bool] = Field(default=None)
285294
centroids: Optional[int]
@@ -449,6 +458,11 @@ def rq(
449458
rescoreLimit=rescore_limit,
450459
)
451460

461+
@staticmethod
462+
def none() -> _UncompressedConfigCreate:
463+
"""Create a a vector index without compression."""
464+
return _UncompressedConfigCreate()
465+
452466

453467
class _VectorIndex:
454468
MultiVector = _VectorIndexMultiVector

0 commit comments

Comments
 (0)