Skip to main content

license: bsl-1.0 task_categories:

  • question-answering
  • text-generation tags:
  • quantum-annealing
  • rag
  • graph-database
  • vector-database
  • pytorch
  • multi-agent
  • memory
  • benchmark size_categories:
  • 1K<n<10K

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

PyPI Version Zenodo DOI Hugging Face Open In Colab

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


⚛️ Core Scientific Breakthroughs

1️⃣ Discrete QCBO Hamiltonian Retrieval

Formulates multi-document context selection not as heuristic greedy ranking, but as an exact Global Energy Minimization Problem over an Ising spin-glass Hamiltonian:

$$\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$$

  • 🎯 Unary Relevance ($\mathbf{c}_i \in \mathbb{R}^N$): Maximizes semantic and lexical query alignment on the Hamiltonian diagonal.
  • 🧲 Ferromagnetic Couplings ($Q_{ij} < 0$): Implements attractive potential wells across relational hyperedges, actively pulling complete multi-hop causal chains into the ground state.
  • 🛡️ Anti-Ferromagnetic Contradiction Walls ($Q_{ik} = +50.0\text{ J}$): Imposes infinite energetic barriers between conflicting, negated, or superseded facts, strictly forbidding mutual co-selection.

2️⃣ Differentiable PyTorch Neural Memory (qdb.nn)

Replaces external text prompt stuffing with direct in-model latent conditioning:

  • Zero-Token Prompt Overhead: Transformer hidden states $\mathbf{h}t \in \mathbb{R}^{d{\text{model}}}$ cross-attend directly to in-VRAM factual key/value memory tensors $(K_{\text{mem}}, V_{\text{mem}})$ during the forward pass.
  • 🔄 Differentiable Gating: Features learnable projection matrices $(W_q, W_k, W_v, W_o)$ and a residual gate $\sigma(\alpha)$ trainable via standard backpropagation while base LLM parameters remain frozen.

3️⃣ In-VRAM Thermodynamic Logit Interceptor

An inline GPU decoding shield that monitors latent hidden-state semantic resonance in real time:

  • 🔒 Boltzmann Heat Penalty: Dynamically intercepts unnormalized vocabulary logits $\mathbf{z}_t \in \mathbb{R}^{V}$ prior to sampling and injects a $+50.0\text{ J}$ thermodynamic penalty onto hallucinated or contradictory tokens.
  • 📉 Absolute Hallucination Suppression: Drives the probability of sampling invalid claims down to $P(\text{false}) \le 1.9 \times 10^{-22}$.

4️⃣ Native Multi-Agent Workflow Engine (qdb.Workflow)

A zero-dependency, ultra-fast agentic orchestration engine engineered from the ground up:

  • $6.79\ \mu\text{s}$ Node Transitions: Executes state dispatch 176× faster than LangGraph with zero Pydantic v1 conflicts.
  • Deterministic Time-Travel & State Forking: Implements immutable SHA-256 state hashing with fork() and bi-directional checkpoints (save_checkpoints() / load_checkpoints()).
  • 📉 Lyapunov Energy Convergence: Bounds recursive agent retries through dissipative energy descent, mathematically preventing infinite loops.

📊 Empirical 4-Way Head-to-Head Benchmark

Evaluated against a 6-hop causal dependency chain with injected temporal traps, entity attractors, and contradictory statements:

Retrieval Architecture / Engine 6-Hop Causal Lineage Continuity Contradiction Leakage Rate Retrieval Latency
🔴 Dense Vector RAG (Qdrant + MMR) 50.0% (Broken at Hop 2) 100% (Leaked) 2.89 ms
🟠 Microsoft GraphRAG (Leiden) 33.3% (Community Cutoff) 100% (Leaked) 36.41 ms
🔵 HippoRAG (Stanford & OSU, NeurIPS 2024) 50.0% (Damped at Hop 4) 100% (Leaked) 4.13 ms
🟢 ⚛️ QDB Deductive Engine (Ours) 100.0% (Unbroken Chain) 0.0% (Clean Ground State) 3.24 ms

💻 Installation & Dual-Mode Usage

pip install --upgrade qdb-ai==2.2.5

🧠 Usage 1: In-Transformer PyTorch Neural Memory (qdb.nn)

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import qdb
from qdb import Vault
from qdb.nn import inject_memory_into_llm

# 1. Ingest Knowledge into Vault
vault = Vault("science_memory", purge=True, embedder="fast")
vault.ingest("Nexus Dynamics engineered the Chronos Sensor Array in Cambridge during 2021.")
vault.ingest("The Chronos Sensor Array utilizes sub-atomic resonance crystals manufactured by Aether Labs.")
vault.ingest("The Almaty facility is directed by Dr. Elena Rostov who holds the master telemetry decryption key.")

# 2. Load Base LLM (e.g. LLaMA-3, Mistral, GPT-2, Gemma)
base_llm = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")

# 3. Inject In-Model Neural Memory (0 Prompt Tokens Consumed!)
grounded_llm = inject_memory_into_llm(
    model=base_llm,
    vault=vault,
    inject_layers="all"
)

# 4. Generate Grounded Output
output = grounded_llm.generate_grounded(
    tokenizer=tokenizer,
    prompt="Who holds the master telemetry key for the Cambridge sensor array?",
    max_new_tokens=40
)
print(output)

⚡ Usage 2: Ultra-Fast Multi-Agent Workflow Engine (qdb.Workflow)

import qdb
from qdb import Workflow, Agent, WorkflowState, Vault

vault = Vault("company_knowledge")
vault.ingest("Alpha Protocol requires dual cryptographic multi-signature authorization.")

def researcher_action(state: WorkflowState) -> WorkflowState:
    facts = state.vault.ask(state.current_task, hops=4)
    state.context_memory["verified_facts"] = str(facts)
    return state

researcher = Agent(
    name="SecurityAnalyst",
    system_prompt="Verify cryptographic security protocols.",
    action_fn=researcher_action
)

wf = Workflow(name="CryptoAuditPipeline", vault=vault)
wf.add_agent(researcher)
wf.set_entry_point("SecurityAnalyst")

initial_state = WorkflowState(
    current_task="What authorization is required for Alpha Protocol?",
    vault=vault
)

# Sub-7 microsecond deterministic state execution
final_state = wf.run(initial_state)
print("Pipeline Output:", final_state.context_memory["verified_facts"])

📜 Citing QDB

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

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.3.0.tar.gz (131.7 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.3.0-py3-none-any.whl (144.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qdb_ai-2.3.0.tar.gz
  • Upload date:
  • Size: 131.7 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.3.0.tar.gz
Algorithm Hash digest
SHA256 8021c7ff642a3c5e19768181604d195821a271543b68ebbb08a97a0d5d881390
MD5 2225f5f9c9aeca8bdf9b33db7a02ed91
BLAKE2b-256 23771f462d96d2b20f7885b3ed1bd656972a8c09d328bddff3374eecb04e14f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qdb_ai-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 144.2 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 467a47d1bca94b9aa436cc6df425d85d29932b66c6ffcce7289be02e3acadc66
MD5 b01d04a830bec5c7d329f1a0d0e47060
BLAKE2b-256 c1e7a7b0eadb20ce387bcf483b1748359107fe5881c4f0d8d0036a8576af02ac

See more details on using hashes here.

Release history Release notifications | RSS feed

2.3.4

2 files

2.3.3

2 files

2.3.1

2 files

This release

2.3.0 This release

2 files

2.2.9

2 files

2.2.8

2 files

2.2.7

2 files

2.2.6

2 files

2.2.5

2 files

2.2.4

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