Embedded two-stage cascading vector index (1-bit graph routing + 3-bit TurboQuant + exact rerank)
Project description
quantal (Python)
Embedded, in-memory vector index — 1-bit graph routing + 3-bit TurboQuant payloads + exact rerank — with a ctypes binding to the Zig core.
Install
pip install -e python # from a source checkout (builds libs on demand)
quantal fixes the vector dimension at compile time, so there is one native library per dimension. The binding resolves it automatically, in order:
QUANTAL_LIB— an explicit library path (overrides everything).- Bundled binary — the published wheels carry prebuilt libraries for the
common embedding dimensions (256, 384, 512, 768, 1024, 1536, 3072), so
pip install quantalworks with no toolchain for those dims. - Cached build under
~/.cache/quantal/. - Build on demand — from a source checkout with
zigon PATH,Index(dim=N)builds and caches the library for any other dimension.
So a stock embedding model "just works" from a wheel; an unusual dimension
needs either a source checkout (auto-build) or a manual
zig build -Dc-dim=N + QUANTAL_LIB.
Building wheels
cd python
python build_libs.py # compile bundled dims into quantal/_libs/
python -m build --wheel # -> dist/quantal-...-py3-none-<platform>.whl
build_libs.py --target x86_64-linux-gnu.2.28 pins glibc so the Linux wheel
is manylinux-compatible (Zig cross-compiles directly — no Docker). CI in
.github/workflows/wheels.yml builds Linux/macOS/Windows wheels this way.
Core API
import numpy as np
from quantal import Index
with Index(dim=384) as index:
ids = index.add(vectors) # (n, 384) float32 -> auto ids
hits = index.search(query, k=10) # -> [(id, score), ...] cosine
scores, ids, counts = index.search_batch(queries, k=10, threads=0)
index.remove(ids[0])
index.save("docs.tq")
index = Index.load("docs.tq") # dimension read from the file
search_filtered(query, allowlist, k) restricts results to a set of ids
(exact scoring over the allowlist — for tenant/ACL filtering).
LangChain
A one-line swap for the in-memory / FAISS store:
from quantal.langchain import QuantalVectorStore
vs = QuantalVectorStore.from_texts(texts, embedding=my_embeddings,
metadatas=metas)
docs = vs.similarity_search("query", k=5)
retriever = vs.as_retriever(search_kwargs={"k": 5})
vs.save("store.qj") # store.qj.tq + store.qj.json
vs = QuantalVectorStore.load("store.qj", embedding=my_embeddings)
Vectors are L2-normalized in and out, so scores are cosine similarity. The
engine stores vectors keyed by id; documents and metadata live in a JSON
sidecar persisted next to the .tq.
LlamaIndex
from quantal.llama_index import QuantalVectorStore
from llama_index.core import VectorStoreIndex, StorageContext
store = QuantalVectorStore() # dim inferred from nodes
ctx = StorageContext.from_defaults(vector_store=store)
index = VectorStoreIndex(nodes, storage_context=ctx, embed_model=embed)
hits = index.as_retriever(similarity_top_k=5).retrieve("query")
LangGraph (agent memory)
A BaseStore with semantic search — local, fast short/long-term memory for
agent graphs. Per-namespace search is served by quantal's exact allowlist
scoring, so namespaces are isolated precisely.
from quantal.langgraph_store import QuantalStore
store = QuantalStore(index={"dims": 384, "embed": embed_fn, "fields": ["text"]})
store.put(("memories", "alice"), "m1", {"text": "prefers dark mode"})
hits = store.search(("memories", "alice"), query="ui preferences", limit=5)
Without an index config it is a plain namespaced key-value store.
Tests
QUANTAL_LIB=... python python/tests/test_index.py
python python/tests/test_langchain.py # needs langchain-core
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quantaldb-0.1.0-py3-none-win_amd64.whl.
File metadata
- Download URL: quantaldb-0.1.0-py3-none-win_amd64.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03d7c2876649afae7fc32318fa9cb3b668f8032d2706342f287e48067045a54f
|
|
| MD5 |
20bdf83c20eb2ae1e67f2f435491f4b0
|
|
| BLAKE2b-256 |
6baf31c95249b6a073e62cc983ec6aa3c03ec99b3f2efef13fce1c65873665de
|
Provenance
The following attestation bundles were made for quantaldb-0.1.0-py3-none-win_amd64.whl:
Publisher:
wheels.yml on PaytonWebber/quantal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantaldb-0.1.0-py3-none-win_amd64.whl -
Subject digest:
03d7c2876649afae7fc32318fa9cb3b668f8032d2706342f287e48067045a54f - Sigstore transparency entry: 1722512452
- Sigstore integration time:
-
Permalink:
PaytonWebber/quantal@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PaytonWebber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quantaldb-0.1.0-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: quantaldb-0.1.0-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 8.3 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11eefe6675e7c24508256c7e30fc1a20666b94434d98b1d5d0adcc383d6e6458
|
|
| MD5 |
56dfb0103c1edf92e872062e9ca2c978
|
|
| BLAKE2b-256 |
aaa25af796d5d943b257258a0e7557bbbe2b0d1debd462d19e9688a50d8d310a
|
Provenance
The following attestation bundles were made for quantaldb-0.1.0-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on PaytonWebber/quantal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantaldb-0.1.0-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
11eefe6675e7c24508256c7e30fc1a20666b94434d98b1d5d0adcc383d6e6458 - Sigstore transparency entry: 1722512539
- Sigstore integration time:
-
Permalink:
PaytonWebber/quantal@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PaytonWebber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quantaldb-0.1.0-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: quantaldb-0.1.0-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.0 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4fc75f742655f48b407564fd5e5335385226df752f5812d9b06d4da2a825179
|
|
| MD5 |
26c9e3a1e61fdfb1cfea1b7ca0840f46
|
|
| BLAKE2b-256 |
d27bab12a2969a187b7127c0a39acd5fe3847757f293213afd984ca36b53c3ab
|
Provenance
The following attestation bundles were made for quantaldb-0.1.0-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
wheels.yml on PaytonWebber/quantal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantaldb-0.1.0-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
e4fc75f742655f48b407564fd5e5335385226df752f5812d9b06d4da2a825179 - Sigstore transparency entry: 1722512656
- Sigstore integration time:
-
Permalink:
PaytonWebber/quantal@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PaytonWebber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quantaldb-0.1.0-py3-none-macosx_14_0_arm64.whl.
File metadata
- Download URL: quantaldb-0.1.0-py3-none-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
403a4c0b270a8037687e466c9176ee4579f2634e3336c458665696ee8a248cd5
|
|
| MD5 |
39fee438f4b4e5bec5f22c7e19b91a1a
|
|
| BLAKE2b-256 |
454febd89be69ab21f733c379bf9cc704b795d526fdfc1dd6fbbaac43a39188a
|
Provenance
The following attestation bundles were made for quantaldb-0.1.0-py3-none-macosx_14_0_arm64.whl:
Publisher:
wheels.yml on PaytonWebber/quantal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantaldb-0.1.0-py3-none-macosx_14_0_arm64.whl -
Subject digest:
403a4c0b270a8037687e466c9176ee4579f2634e3336c458665696ee8a248cd5 - Sigstore transparency entry: 1722512739
- Sigstore integration time:
-
Permalink:
PaytonWebber/quantal@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/PaytonWebber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@42064b4f6edc8ab1f972a598273b46611e3f1086 -
Trigger Event:
push
-
Statement type: