Skip to main content

quantal (Python)

Embedded, in-memory vector index with 1-bit graph routing, 3-bit TurboQuant payloads, exact rerank, and 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:

  1. QUANTAL_LIB: an explicit library path (overrides everything).
  2. Bundled binary: the published wheels carry prebuilt libraries for the common embedding dimensions (256, 384, 512, 768, 1024, 1536, 3072), so pip install quantaldb works with no toolchain for those dims.
  3. Cached build under ~/.cache/quantal/.
  4. Build on demand: from a source checkout with zig on PATH, Index(dim=N) builds and caches the library for any other dimension.

Common embedding dimensions can use the bundled wheel; any other dimension needs either a source checkout with 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 needed. 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. It uses exact scoring over the allowlist for tenant and 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 for local short/long-term memory in 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

Metadata

Release files for quantaldb 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for quantaldb 0.1.1
File Actions
quantaldb-0.1.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for quantaldb-0.1.1-py3-none-win_amd64.whl
quantaldb-0.1.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for quantaldb-0.1.1-py3-none-manylinux_2_28_x86_64.whl
quantaldb-0.1.1-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for quantaldb-0.1.1-py3-none-manylinux_2_28_aarch64.whl
quantaldb-0.1.1-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details for quantaldb-0.1.1-py3-none-macosx_14_0_arm64.whl

Total release size: 40.8 MB

Release files / quantaldb-0.1.1-py3-none-win_amd64.whl

Download URL quantaldb-0.1.1-py3-none-win_amd64.whl
Size 6.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
823b943c1d88ba2039da1423eda5ebeb243d18e3a435a0ff537806ba0035aff1
BLAKE2b-256 checksum
How to use checksums
936bb80de03ef087c3c0d9b542908f704d6486010c7509050411f0e3e514ab4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Release files / quantaldb-0.1.1-py3-none-manylinux_2_28_x86_64.whl

Download URL quantaldb-0.1.1-py3-none-manylinux_2_28_x86_64.whl
Size 25.1 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
cb963956bc2ddafbd7b1bd23d855f5a545a68ce245eae36600ba911dd2076fdc
BLAKE2b-256 checksum
How to use checksums
43b705d3a39978a18cb916d65c874b1d56230efd6ad81f5b9d48bafa26a91c50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Release files / quantaldb-0.1.1-py3-none-manylinux_2_28_aarch64.whl

Download URL quantaldb-0.1.1-py3-none-manylinux_2_28_aarch64.whl
Size 8.0 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2f3590766f6f684392918110b56d9c68f624bbd411f9319bdaba46b73259a4b3
BLAKE2b-256 checksum
How to use checksums
4a3627aa2a405c61ffb0138092196e2d3e1998e9ad2b115f30cc46829dd6aedb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Release files / quantaldb-0.1.1-py3-none-macosx_14_0_arm64.whl

Download URL quantaldb-0.1.1-py3-none-macosx_14_0_arm64.whl
Size 1.4 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
a9f8080e4eb4440c79ae2574d883cc82ae47b81a0fb35b3f2e8a0f97b5fdba7a
BLAKE2b-256 checksum
How to use checksums
eaf1764cc656a2774df12fece122d0574274dd1bca05369aad6a231cb9e9aae5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Security for quantaldb 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for quantaldb-0.1.1-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page