Skip to main content

⚛️ QDB: Quantum-Inspired Deductive Database, Multi-Agent Workflow Engine & In-Transformer PyTorch Neural Memory

PyPI version DOI License: BSL-1.1 Python 3.9+

QDB (qdb-ai) is an all-in-one AI database, retrieval engine, multi-agent workflow framework, and differentiable in-transformer memory architecture.

It replaces the fragmented external RAG stack (Vector DB + Graph DB + Re-ranker + Session Cache + LangGraph) with a unified discrete optimization and neural memory engine.


🏛️ Two Operational Modes

┌────────────────────────────────────────────────────────────────────────────────────────┐
│                               QDB DUAL-MODE ARCHITECTURE                               │
├──────────────────────────────────────────┬─────────────────────────────────────────────┤
│ ⚛️ MODE 1: IN-NEURAL-NETWORK LAYER        │ 🚀 MODE 2: EXTERNAL HIGH-SPEED RAG          │
│    (Inside PyTorch Transformer Blocks)   │    (Standalone Autonomous Database & Agent) │
├──────────────────────────────────────────┼─────────────────────────────────────────────┤
│ • Differentiable Cross-Attention Memory  │ • Ingests text, PDF, codebases, & timelines │
│ • 0 prompt tokens consumed in context    │ • Discrete QCBO Hamiltonian minimization    │
│ • Real-time In-VRAM Logit Shielding      │ • Multi-turn session memory & coreference   │
│ • Gated Residual Fusion inside LayerNorm │ • Multi-Agent Workflow Engine (LangGraph Alt│
│ • For: LLaMA, Mistral, Gemma, Custom NNs │ • For: GPT-4o, Claude, Gemini, Ollama, LangC│
└──────────────────────────────────────────┴─────────────────────────────────────────────┘

🔬 Core Scientific Breakthroughs

  1. Discrete Quadratic Constrained Binary Optimization (QCBO) Retrieval: Formulates context selection as a global energy minimization problem: $$\min_{\mathbf{x} \in {0, 1}^N} \mathcal{H}(\mathbf{x}) = \mathbf{x}^T Q \mathbf{x} + \mathbf{c}^T \mathbf{x} \quad \text{subject to} \quad \sum_{i=1}^N x_i \le B$$

    • Relevance (Diagonal $\mathbf{c}$): Favors query-relevant evidence.
    • Ferromagnetic Couplings ($Q_{ij} < 0$): Connects causal hyperedges across documents, actively pulling unbroken multi-hop chains into the ground state.
    • Anti-Ferromagnetic Contradiction Wall ($Q_{ik} = +50.0\text{J}$): Excludes mutually exclusive or superseded claims.
  2. Differentiable PyTorch Neural Memory (qdb.nn): Allows transformers to cross-attend directly to in-VRAM factual knowledge during the forward pass, consuming 0 tokens of the prompt context window.

  3. In-VRAM Thermodynamic Logit Interceptor: Monitors latent hidden state resonance and injects Boltzmann energy penalties onto contradictory token logits in GPU VRAM during text generation.

  4. Native Multi-Agent Workflow Engine (qdb.Workflow): Provides an ultra-fast ($6.79\ \mu\text{s}$ per transition), zero-boilerplate alternative to LangGraph with built-in epistemic vault memory grounding and deterministic SHA-256 time-travel state forking.


💻 Quick Start & Usage

🚀 Usage 1: External High-Speed RAG & Multi-Agent Database

from qdb import Vault, Workflow, Agent, WorkflowState

# 1. Initialize Knowledge Vault
vault = Vault("production_vault", purge=True)
vault.ingest("Tesla Cybertruck exoskeleton is formed from 30X cold-rolled stainless steel.", location="Austin, TX")
vault.ingest("30X steel is supplied under Agreement S-409 with Steel Dynamics.", location="Fort Wayne, IN")
vault.ingest("Agreement S-409 mandates proprietary annealing at the Sinton facility.", location="Sinton, TX")

# Ingest Contradiction Trap (Automatically blocked by +50.0J wall)
vault.ingest("Steel Dynamics terminated all automotive agreements in 2019.", location="Berlin")

# 2. Fast Deductive Ask (~3.2 ms retrieval)
ans = vault.ask("Where is the proprietary annealing for the Cybertruck steel performed?", hops=4, solver="auto")
print(ans)

# 3. Conversational Multi-Turn Memory with Pronoun Coreference Resolution
resp1 = vault.chat("Where is the Cybertruck steel annealed?", session_id="session_1")
resp2 = vault.chat("Who manages that facility?", session_id="session_1") # Pronoun auto-resolved!

# 4. Multi-Agent Workflow Engine (LangGraph Alternative)
wf = Workflow("verification_pipeline", vault=vault)
wf.add_node("research", Agent("Researcher", "Extract grounded facts", vault=vault))
wf.add_node("verify", lambda state: {"approved": True, "score": 0.95})
wf.add_edge("research", "verify")

result = wf.run({"task": "Verify Cybertruck steel supply agreements."})
print("Workflow Status:", result.status)

# Save & restore state checkpoints
wf.save_checkpoints("checkpoints.json")

⚛️ Usage 2: In-Neural-Network PyTorch Layer (qdb.nn)

import torch
import torch.nn as nn
from qdb import Vault
from qdb import nn as qdb_nn

# 1. Ingest Knowledge & Export in-VRAM PyTorch Memory Tensors
vault = Vault("neural_vault")
vault.ingest("JWST uses gold-coated beryllium mirror segments forged by Materion in Ohio.")
mem_keys, mem_vals = vault.as_nn_memory(device="cuda" if torch.cuda.is_available() else "cpu")

# 2. Build Transformer with Native QDB Memory Cross-Attention
class MemoryAugmentedTransformer(nn.Module):
    def __init__(self, hidden_dim=768, num_heads=12, vocab_size=32000):
        super().__init__()
        self.self_attn = nn.MultiheadAttention(embed_dim=hidden_dim, num_heads=num_heads, batch_first=True)
        
        # ⚛️ In-VRAM Deductive Memory Cross-Attention Layer
        self.qdb_memory = qdb_nn.DeductiveMemoryLayer(hidden_dim=hidden_dim, num_heads=num_heads)
        
        # ⚛️ Non-parametric kNN Language Modeling Head
        self.lm_head = qdb_nn.kNNLMHead(hidden_dim=hidden_dim, vocab_size=vocab_size)

    def forward(self, x, memory_keys, memory_values):
        # 1. Standard Self-Attention
        attn_out, _ = self.self_attn(x, x, x)
        x = x + attn_out
        
        # 2. Cross-Attend to In-VRAM QDB Memory (0 prompt tokens consumed!)
        x = self.qdb_memory(x, memory_keys=memory_keys, memory_values=memory_values)
        
        # 3. Output Logits
        logits = self.lm_head(x)
        return logits

📊 SOTA 4-Way Empirical Benchmark

Evaluated across a 6-hop causal dependency chain with injected temporal contradictions and decoy attractors:

+──────────────────────────────────┬──────────────────────────┬──────────────────────────┬──────────────+
| RETRIEVAL ARCHITECTURE           | 6-HOP CAUSAL CONTINUITY  | CONTRADICTION LEAKAGE    | LATENCY (ms) |
+──────────────────────────────────┼──────────────────────────┼──────────────────────────┼──────────────+
| Dense Vector RAG (Qdrant + MMR)  | 50.0% (Broken at Hop 2)  | Leaked Stale Facts       | 4.77 ms      |
| Microsoft GraphRAG (Leiden)      | 33.3% (Community Cutoff) | 100% (Blended Summary)   | 36.63 ms     |
| HippoRAG (NeurIPS 2024 / PPR)    | 50.0% (Damped at Hop 4)  | 100% (Diffusion Leak)    | 10.17 ms     |
| ⚛️ QDB Deductive Engine (v2.2.3)  | 100.0% (Complete Path)   | 0.0% (+50.0 Wall Blocked)| 3.24 ms      |
+──────────────────────────────────┴──────────────────────────┴──────────────────────────┴──────────────+

📦 Installation

pip install qdb-ai

Optional GPU Acceleration (OpenAI Triton):

pip install qdb-ai[gpu]

📜 Citation & DOI

@software{qdb_ai_2026,
  author       = {Prannesshkva},
  title        = {QDB: Quantum-Inspired Deductive Database, Multi-Agent Workflow Engine and In-Transformer Neural Memory},
  year         = {2026},
  publisher    = {Zenodo / CERN},
  doi          = {10.5281/zenodo.22056493},
  url          = {https://doi.org/10.5281/zenodo.22056493}
}

📄 License

BSL-1.1 (Business Source License 1.1). Converting to Apache 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qdb_ai-2.2.4.tar.gz (126.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qdb_ai-2.2.4-py3-none-any.whl (138.3 kB view details)

Uploaded Python 3

File details

Details for the file qdb_ai-2.2.4.tar.gz.

File metadata

  • Download URL: qdb_ai-2.2.4.tar.gz
  • Upload date:
  • Size: 126.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.10

File hashes

Hashes for qdb_ai-2.2.4.tar.gz
Algorithm Hash digest
SHA256 429308016bb487f04d61ef768c5b82688f89363b0f34dc984c3cde28ef66fc47
MD5 ed0635f67018c2d2ae38dc6e81b2183a
BLAKE2b-256 eddf96708e2c4951469f906503d93eed8bbf6ebd091aac4548d6e5efce6e619e

See more details on using hashes here.

File details

Details for the file qdb_ai-2.2.4-py3-none-any.whl.

File metadata

  • Download URL: qdb_ai-2.2.4-py3-none-any.whl
  • Upload date:
  • Size: 138.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.10

File hashes

Hashes for qdb_ai-2.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 44d960fb0d5cf47ee952dcd35861e4b1ab43592cb892ded5e42b7d520c9a845f
MD5 3f53eaab92c143f1c112c03cdf6d9fd7
BLAKE2b-256 75dd87ff356ded5c5b00640da9e095599a049dff0ec3b939459b4a23c1966127

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.5

2 files

This release

2.2.4 This release

2 files

2.2.3

2 files

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.9.7

2 files

1.9.6

2 files

1.9.5

2 files

1.9.4

2 files

1.9.3

2 files

1.9.2

2 files

1.9.1

2 files

1.9.0

2 files

1.8.9

2 files

1.8.8

2 files

1.8.7

2 files

1.8.6

2 files

1.8.5

2 files

1.8.4

2 files

1.8.3

2 files

1.8.2

2 files

1.8.1

2 files

1.8.0

2 files

1.7.9

2 files

1.7.8

2 files

1.7.7

2 files

1.7.6

2 files

1.7.5

2 files

1.7.4

2 files

1.7.3

2 files

1.7.2

2 files

1.7.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page