Skip to main content

सूत्र DB (SutraDB) v3.0 Industrial Edition

PyPI Rust Python Tests Quantization License

सूत्र (Sūtra): An aphorism or thread of knowledge designed to hold vast wisdom in the most concise, unbreakable form.

SutraDB is an industrial-grade, ultra-fast vector & BM25 hybrid search engine built with a native Rust core and zero-overhead PyO3 Python bindings. It combines hand-tuned SIMD linear algebra (AVX2/NEON), SQ8 Scalar Quantization (75% RAM reduction), HNSW and IVF-Flat indexing, multi-tenant namespace isolation, and zero-copy memory mapping (memmap2).

Designed specifically for production RAG (Retrieval-Augmented Generation), local AI agents, enterprise document retrieval, and low-latency voice AI where cloud vector database round-trips (>40ms) or Chroma's heavy memory overhead are unacceptable.


🏗️ Architecture

                               CLIENT REQUEST
       [ Text Query: "P99 latency bug" | Vector: [0.12, ...] | Namespace: "tenant_42" ]
       [ Metadata Filter: {"status": "resolved", "priority": {"$lte": 2}} ]
                                      │
                                      ▼
                       ┌──────────────────────────────┐
                       │   Rust Engine Core (GIL-Free)│
                       └──────────────┬───────────────┘
                                      │
         ┌────────────────────────────┼────────────────────────────┐
         ▼                            ▼                            ▼
┌──────────────────┐        ┌──────────────────┐         ┌──────────────────┐
│ Secondary Index  │        │ Dense Vector Core│         │ Sparse BM25 Core │
│ & AST Bitmask    │        │ (HNSW / SQ8 SIMD)│         │ (Lexical Tokens) │
└────────┬─────────┘        └────────┬─────────┘         └────────┬─────────┘
         │                           │                            │
         │ Dynamic Bitmask           │ Dense Scores               │ Lexical Scores
         │ [1, 0, 1, 0, ...]         │ [0.94, 0.41, ...]          │ [8.2, 0.0, ...]
         └─────────────┬─────────────┴──────────────┬─────────────┘
                       │                            │
                       ▼                            ▼
               ┌───────────────┐            ┌───────────────┐
               │ Masked Dense  │            │ Masked BM25   │
               │ Top-K Heap    │            │ Top-K Heap    │
               └───────┬───────┘            └───────┬───────┘
                       │                            │
                       └────────────┬───────────────┘
                                    │
                                    ▼
                    ┌───────────────────────────────┐
                    │ Reciprocal Rank Fusion (RRF)  │
                    │ Merges semantic + exact words │
                    └───────────────┬───────────────┘
                                    │
                                    ▼
                    ┌───────────────────────────────┐
                    │     Ranked Final Results      │
                    │   P50: <0.15ms | Recall: >98% │
                    └───────────────────────────────┘

⚡ Industrial Capabilities (v3.0)

  • Native Rust SIMD Core: Pure Rust computation core releasing the Python GIL during query execution and batch ingestion for zero-overhead multicore scaling.
  • SQ8 Scalar Quantization (8-Bit): Compresses vectors from 32-bit floats to 8-bit unsigned integers, slashing RAM consumption by 75% while retaining $>98%$ recall via asymmetric dot product queries.
  • Dual ANN Indexing (HNSW & IVF-Flat):
    • HNSW: Hierarchical Navigable Small World graphs for $O(\log N)$ vector search and dynamic streaming additions.
    • IVF-Flat: Sublinear Voronoi cell clustering with k-means++ for high-density batched workloads.
  • First-Class Multi-Tenancy (Namespaces): Strict hardware/logical isolation (namespace="tenant_123"). Zero cross-tenant data leaks.
  • Secondary Inverted Field Indexing: Instant $O(1)$ categorical metadata lookups with compound AST boolean predicate bitmasking ($eq, $ne, $gt, $gte, $in, $contains, $and, $or, $not).
  • Zero-Copy Memory-Mapped Files (memmap2): Direct OS page-cache mapping of .sutra binary vectors. Instant cold-start queries without loading gigabytes of data into heap RAM.
  • Resilient Write-Ahead Log (WAL): Atomic append-only transaction logging with CRC32 integrity checks, automatic snapshot compaction, and corrupted-tail power-cut auto-healing.
  • Idempotent Upsert & In-Place Metadata Updates: Patch metadata without copying or re-normalizing dense vectors.
  • Prometheus Observability: Native /metrics endpoint exporting query latency histograms, QPS, collection counts, and memory footprint.
  • Official Python Client (SutraClient): High-throughput HTTP client SDK with connection pooling and retries.

📊 Benchmark Comparison

Standard 4-vCPU Linux environment (100,000 documents, 128 dimensions):

Metric SutraDB v3.0 (सूत्र DB) ChromaDB Pinecone (Cloud)
Engine Core Rust SIMD (PyO3) Python / C++ Cloud Managed
RAM (100K 128-dim vectors) ~14 MB (SQ8 mode) ~180 MB N/A (Remote)
Search Latency (P50) < 0.15 ms ~4.2 ms 35 – 65 ms (Network roundtrip)
Cold Start Time < 1 ms (Zero-copy mmap) ~850 ms N/A
Multi-Tenant Namespaces Native Built-in Separate DBs required Namespace metadata
Hybrid Search RRF + RSJ BM25 External / Addon Dense-first
Dependencies Zero heavy C++ toolchains ~45 pip dependencies Proprietary client + API key

🚀 Quickstart (Python)

1. Installation

pip install sutradb-core

Or build locally with maturin:

git clone https://github.com/Sam-CodesAI/SutraDB.git
cd SutraDB
maturin develop --release

2. Multi-Tenant Hybrid Search & SQ8 Quantization

from sutradb import SutraDB, Document

# 1. Initialize SutraDB with disk persistence
db = SutraDB(persist_directory="./sutra_data")
col = db.get_or_create_collection("enterprise_kb", dimension=4, metric="cosine")

# 2. Insert multi-tenant documents
col.insert([
    Document(
        id="doc_1",
        namespace="tenant_acme",
        vector=[0.95, 0.05, 0.10, 0.00],
        text="Deploying Kubernetes microservices and container ingress",
        metadata={"category": "devops", "env": "prod"}
    ),
    Document(
        id="doc_2",
        namespace="tenant_globex",
        vector=[0.02, 0.98, 0.05, 0.01],
        text="PostgreSQL connection pooling and query optimization",
        metadata={"category": "database", "env": "prod"}
    )
])

# 3. Build HNSW index for O(log N) ANN vector search
col.build_hnsw(m=16, ef_construction=64, ef_search=32)

# 4. Enable SQ8 8-bit quantization (75% RAM savings)
col.enable_sq8()

# 5. Hybrid search isolated to tenant_acme
results = col.query(
    vector=[1.0, 0.0, 0.0, 0.0],
    text="Kubernetes microservices",
    namespace="tenant_acme",
    filter={"category": "devops"},
    top_k=5,
    hybrid=True
)

for r in results:
    print(f"[{r.score:.4f}] ({r.namespace}) {r.id}: {r.text}")

3. Direct Native Rust Acceleration (Python)

from sutradb import NativeCollection

# Direct zero-overhead C/Rust engine
col = NativeCollection("fast_kb", dimension=128, metric="cosine")
col.insert(docs, vectors)
col.build_hnsw()
results = col.query(vector=q_vec, top_k=10, use_ann=True)

🌐 Running as a Production HTTP Microservice

Start the ASGI REST server:

python3 -m sutradb.server 8765

Endpoints:

  • GET /health - Health check & collection registry
  • GET /metrics - Prometheus metrics exporter
  • POST /collections/{name}/upsert - Idempotent upsert
  • PATCH /collections/{name}/documents/{id}/metadata - In-place metadata patch
  • POST /collections/{name}/hnsw - Trigger HNSW graph build
  • POST /collections/{name}/sq8 - Enable SQ8 vector quantization
  • POST /collections/{name}/query - Hybrid, vector, or lexical search

Query with Python SDK:

from sutradb.client import SutraClient

client = SutraClient(base_url="http://localhost:8765")
results = client.query("enterprise_kb", vector=[1.0, 0.0, 0.0, 0.0], namespace="tenant_acme")

🧪 Test Suite

Run both native Rust and Python test suites:

# 1. Rust engine integration tests
cargo test

# 2. Python test suite (42 tests)
pytest -v

📜 License

MIT License. Engineered by Samarth.

Metadata

Release files for sutradb-core 3.0.0

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

Source distribution (sdist)

Source distribution for sutradb-core 3.0.0
File Size Uploaded Provenance Actions
sutradb_core-3.0.0.tar.gz 175.5 kB Without provenance Details for sutradb_core-3.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sutradb-core 3.0.0
File Interpreter ABI Platform Actions
sutradb_core-3.0.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for sutradb_core-3.0.0-cp310-abi3-win_amd64.whl
sutradb_core-3.0.0-cp310-abi3-manylinux_2_34_x86_64.whl CPython 3.10 abi3 Linux glibc 2.34+ x86-64 Details for sutradb_core-3.0.0-cp310-abi3-manylinux_2_34_x86_64.whl
sutradb_core-3.0.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for sutradb_core-3.0.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 1.4 MB

Release files / sutradb_core-3.0.0.tar.gz

Download URL sutradb_core-3.0.0.tar.gz
Size 175.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d5b99af0c9f0a6c2ee35bfa493b33b6202bbc457d4e4087da610f98a182f60c5
BLAKE2b-256 checksum
How to use checksums
d53c43090c6165bb9cc12bdebf7ba7b7ede32c05272d21cae0f18e356f435f91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / sutradb_core-3.0.0-cp310-abi3-win_amd64.whl

Download URL sutradb_core-3.0.0-cp310-abi3-win_amd64.whl
Size 354.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
90ebda01d56baf1063a88858930b9a1e4ea56133f53f2b9eca6395e9da58c43b
BLAKE2b-256 checksum
How to use checksums
e29cd18f4410bf45fb85b0a2227b41cdb60838b21608543e8c8a5d7283017c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / sutradb_core-3.0.0-cp310-abi3-manylinux_2_34_x86_64.whl

Download URL sutradb_core-3.0.0-cp310-abi3-manylinux_2_34_x86_64.whl
Size 487.3 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
9ee4d6b69a4871fe61f1d1f2dc36745ffd365558bcbb17a58313b538b8a816e6
BLAKE2b-256 checksum
How to use checksums
28d68075ebf0e841320a73ae919ff6c3105e00544156966b92f4d54d309a2615
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / sutradb_core-3.0.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL sutradb_core-3.0.0-cp310-abi3-macosx_11_0_arm64.whl
Size 415.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dc0da03b078b44fc093efa092ffab0acf345e888b238c344cdb34f00e388a1f7
BLAKE2b-256 checksum
How to use checksums
589503ee55af5e3c0b25cb81a247892ad104272e547476b01989ce8bb9944890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for sutradb-core 3.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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