Skip to content

Commit ab8b7e2

Browse files
committed
fixed the comments
1 parent 8de7a7e commit ab8b7e2

5 files changed

Lines changed: 34 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![MIT License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
88
[![Tests](https://img.shields.io/badge/tests-375%20passing-brightgreen)](tests/)
99

10-
Write `INSERT`, `SEARCH`, `RECOMMEND`, `DELETE`, and `CREATE COLLECTION` statements instead of Python SDK calls. Supports hybrid dense+sparse vector search, cross-encoder reranking, quantization (scalar, binary, product), SQL-style `WHERE` filters, script execution, and collection dump/restore.
10+
Write `INSERT`, `SEARCH`, `RECOMMEND`, `DELETE`, and `CREATE COLLECTION` statements instead of Python SDK calls. Supports hybrid dense+sparse vector search, cross-encoder reranking, quantization (scalar, turbo, binary, product), SQL-style `WHERE` filters, script execution, and collection dump/restore.
1111

1212
```
1313
qql> INSERT INTO COLLECTION notes VALUES {'text': 'Qdrant is a vector database', 'author': 'alice', 'year': 2024}
@@ -84,7 +84,7 @@ Full documentation lives in the [`docs/`](docs/) folder and at **[pavanjava.gith
8484
| [INSERT / INSERT BULK](docs/insert.md) | Adding documents, batch inserts, payload types |
8585
| [SEARCH / RECOMMEND / Hybrid / RERANK](docs/search.md) | Semantic search, hybrid, reranking, recommendations |
8686
| [WHERE Filters](docs/filters.md) | Full SQL-style filter operators |
87-
| [Collections & Quantization](docs/collections.md) | CREATE, DROP, QUANTIZE (scalar/binary/product), CREATE INDEX |
87+
| [Collections & Quantization](docs/collections.md) | CREATE, DROP, QUANTIZE (scalar/turbo/binary/product), CREATE INDEX |
8888
| [Scripts: EXECUTE / DUMP](docs/scripts.md) | Script files, collection backup/restore |
8989
| [Programmatic Usage](docs/programmatic.md) | Use QQL as a Python library |
9090
| [Reference: Models / Config / Errors](docs/reference.md) | Embedding models, config file, error reference |

docs/collections.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ When `USING MODEL` is omitted, the collection uses the **default embedding model
6767

6868
## Quantization — QUANTIZE clause
6969

70-
Quantization reduces the memory footprint of vector collections and speeds up search at the cost of a small, controllable accuracy loss. QQL supports all three Qdrant quantization strategies via an optional `QUANTIZE` clause appended to `CREATE COLLECTION`.
70+
Quantization reduces the memory footprint of vector collections and speeds up search at the cost of a small, controllable accuracy loss. QQL supports all four Qdrant quantization strategies via an optional `QUANTIZE` clause appended to `CREATE COLLECTION`.
7171

7272
**Four strategies:**
7373

@@ -87,15 +87,18 @@ CREATE COLLECTION <name> ... QUANTIZE PRODUCT [ALWAYS RAM]
8787
```
8888

8989
- **`QUANTILE <float>`** — (SCALAR only) calibration quantile for the INT8 conversion; defaults to Qdrant's built-in default (0.99) when omitted.
90-
- **`BITS <depth>`** — (TURBO only) bit depth controlling compression ratio:
91-
- `4` — 4-bit, **** compression (default when `BITS` is omitted)
92-
- `2` — 2-bit, **16×** compression
93-
- `1.5` — 1.5-bit, **24×** compression
94-
- `1` — 1-bit, **32×** compression (same ratio as BINARY, but better recall)
90+
- **`BITS <depth>`** — (TURBO only) bit depth passed to the Qdrant SDK:
91+
- `4` — 4-bit (default when `BITS` is omitted; server applies its own default)
92+
- `2` — 2-bit
93+
- `1.5` — 1.5-bit
94+
- `1` — 1-bit
95+
> Compression ratios (8×, 16×, 24×, 32×) and recall characteristics are
96+
> Qdrant server-side behaviors. QQL maps the `BITS` value to the SDK model and
97+
> passes it to Qdrant; actual results depend on your Qdrant server version.
9598
- **`ALWAYS RAM`** — keep the **quantized** vectors in RAM at all times, regardless of the collection's `on_disk` setting. Improves search throughput at the cost of higher RAM usage for the compressed index. The original full-precision vectors are stored and managed independently of this flag. Supported by all four quantization types.
9699
- **`QUANTIZE`** always appears **after** all other clauses (`HYBRID`, `USING MODEL`, etc.).
97100
- For `PRODUCT`, the compression ratio is fixed at **** in this version.
98-
- For `TURBO`, all distance metrics are supported; `TURBO` fully supports Cosine, Dot, and Euclidean with SIMD-accelerated scoring.
101+
- For `TURBO`, Cosine, Dot, and Euclidean distance are supported by the Qdrant server when TurboQuant is enabled.
99102
- When used with `HYBRID` collections, quantization applies only to the **dense** vector.
100103

101104
**Examples:**

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "qql-cli"
33
version = "2.0.0"
4-
description = "QQL is a SQL-like query language and CLI for Qdrant vector database. Write INSERT, SEARCH, RECOMMEND, DELETE, and CREATE COLLECTION statements instead of Python SDK calls. Supports hybrid dense+sparse vector search, cross-encoder reranking, quantization (scalar, binary, product), WHERE clause filters, script execution, and collection dump/restore."
4+
description = "QQL is a SQL-like query language and CLI for Qdrant vector database. Write INSERT, SEARCH, RECOMMEND, DELETE, and CREATE COLLECTION statements instead of Python SDK calls. Supports hybrid dense+sparse vector search, cross-encoder reranking, quantization (scalar, turbo, binary, product), WHERE clause filters, script execution, and collection dump/restore."
55
readme = "README.md"
66
license = { file = "LICENSE" }
77
requires-python = ">=3.12"

src/qql/executor.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,15 @@ def _build_quantization_config(
877877
1.5: TurboQuantBitSize.BITS1_5,
878878
1.0: TurboQuantBitSize.BITS1,
879879
}
880-
bits_enum = _BITS_MAP.get(qc.turbo_bits or 4.0, TurboQuantBitSize.BITS4)
880+
if qc.turbo_bits is None:
881+
bits_enum = None # user omitted BITS → preserve None, server applies default
882+
elif qc.turbo_bits in _BITS_MAP:
883+
bits_enum = _BITS_MAP[qc.turbo_bits]
884+
else:
885+
raise QQLRuntimeError(
886+
f"Unsupported TURBO bit depth: {qc.turbo_bits}. "
887+
f"Valid values: 1, 1.5, 2, 4"
888+
)
881889
return TurboQuantization(
882890
turbo=TurboQuantQuantizationConfig(
883891
bits=bits_enum,

tests/test_executor.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,15 +1661,16 @@ def test_turbo_passes_turbo_quantization(self, executor, mock_client):
16611661
kw = mock_client.create_collection.call_args.kwargs
16621662
assert isinstance(kw.get("quantization_config"), TurboQuantization)
16631663

1664-
def test_turbo_default_bits_is_bits4(self, executor, mock_client):
1665-
from qdrant_client.models import TurboQuantBitSize
1664+
def test_turbo_default_bits_is_none(self, executor, mock_client):
1665+
"""When BITS is omitted, bits must be None — preserving omission so the
1666+
SDK/server applies its own default rather than QQL forcing BITS4."""
16661667
node = CreateCollectionStmt(
16671668
collection="articles",
16681669
quantization=QuantizationConfig(type=QuantizationType.TURBO),
16691670
)
16701671
executor.execute(node)
16711672
kw = mock_client.create_collection.call_args.kwargs
1672-
assert kw["quantization_config"].turbo.bits == TurboQuantBitSize.BITS4
1673+
assert kw["quantization_config"].turbo.bits is None
16731674

16741675
def test_turbo_bits2(self, executor, mock_client):
16751676
from qdrant_client.models import TurboQuantBitSize
@@ -1738,3 +1739,11 @@ def test_turbo_result_message_includes_turbo(self, executor, mock_client):
17381739
)
17391740
result = executor.execute(node)
17401741
assert "turbo" in result.message
1742+
1743+
def test_turbo_invalid_bits_at_executor_raises(self, executor, mock_client):
1744+
"""An unexpected turbo_bits value that bypasses parser validation must
1745+
raise QQLRuntimeError explicitly instead of silently coercing to BITS4."""
1746+
from qql.exceptions import QQLRuntimeError as QQLErr
1747+
qc = QuantizationConfig(type=QuantizationType.TURBO, turbo_bits=3.0)
1748+
with pytest.raises(QQLErr, match="Unsupported TURBO bit depth"):
1749+
executor._build_quantization_config(qc)

0 commit comments

Comments
 (0)