⚛️ QDB: Quantum-Inspired Deductive Database, Multi-Agent Workflow Engine & In-Transformer PyTorch Neural Memory
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
-
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.
-
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. -
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.
-
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
Built Distribution
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 qdb_ai-2.2.5.tar.gz.
File metadata
- Download URL: qdb_ai-2.2.5.tar.gz
- Upload date:
- Size: 129.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b8db13190d7006e6aa3952d5bb0088c9d0a68a91a9a23801a9b6a21ccd88c53
|
|
| MD5 |
b388b0ff1640247c44a3c9bbdd342ddd
|
|
| BLAKE2b-256 |
7b6e53022c54c6c4ce8331159d0a2898aace3004e4c21de01029ba03fcd8b9ef
|
File details
Details for the file qdb_ai-2.2.5-py3-none-any.whl.
File metadata
- Download URL: qdb_ai-2.2.5-py3-none-any.whl
- Upload date:
- Size: 142.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2d5d17c98e6bdbbf15da757bd3cbdc2b4518f496b78d2095ba2dd1cb0d0826a
|
|
| MD5 |
b36036535ea4477e9348a754b058d750
|
|
| BLAKE2b-256 |
6867a090f7c0fdf3702b4eb0be3b5e4a8f5a655d65eb8674c4fa70f537ad2ae4
|