qdb-rs - Quantum Database
A hybrid quantum-classical database leveraging the QFT format for polynomial storage complexity and fault-tolerant error correction. Built on qft-rs and designed for integration with the LogosQ quantum simulation ecosystem.
Features
- Quantum State Storage: Store and retrieve quantum states using the
.qftformat - MPS Compression: O(n χ²) storage complexity via Matrix Product State decomposition
- Golay Error Correction: [23,12,7] classical Golay codes for fault-tolerant persistence
- Grover-Inspired Search: O(√N) search complexity for unstructured queries
- ACID Transactions: Quantum-aware transaction semantics with entanglement groups
- Multiple Backends: Memory, disk, and extensible backend abstraction
- Radiation Hardening: SEU mitigation modes for space applications
- Post-Quantum Security: ML-KEM signing support via QFT format
Installation
[]
= { = "0.1", = ["full"] }
# Required peer dependency
= "1.0"
# Optional: LogosQ integration
= { = "0.2", = true }
Feature Flags
| Feature | Description |
|---|---|
default |
Core functionality |
async |
Tokio-based async I/O |
logosq |
LogosQ MPS bridge methods |
radiation |
Radiation hardening modes |
full |
All features enabled |
Quick Start
use *;
Architecture
┌─────────────────────────────────────────────────────────────┐
│ QDB API Layer │
├─────────────────────────────────────────────────────────────┤
│ Key-Value API │ Document API │ Quantum State API │
├─────────────────────────────────────────────────────────────┤
│ Query Engine │
│ - Grover search (O(√N)) │
│ - Tensor contractions for joins │
│ - Variational optimization │
├─────────────────────────────────────────────────────────────┤
│ Storage Layer │
│ - QFT serialization (MPS tensors) │
│ - Golay error correction │
│ - Adaptive bond dimension │
├─────────────────────────────────────────────────────────────┤
│ Backend Abstraction │
│ Memory │ Disk │ Distributed │ Quantum Hardware │
└─────────────────────────────────────────────────────────────┘
Storage Backends
Memory Backend
Fast, in-memory storage using DashMap for concurrent access:
let db = QDBnew;
Disk Backend
Persistent storage with checksums and Golay protection:
let db = QDBnew;
Quantum Operations
Storing Quantum States
use QftBuilder;
// Create a custom quantum state
let state = new
.bond_dimension
.golay
.metadata
.build?;
db.put_quantum?;
Grover Search
use GroverSearch;
// Search for entries matching a predicate
let search = new;
let candidates = search.search?;
Transactions
Basic Transactions
let manager = new;
let tx = manager.begin;
tx.put?;
tx.put?;
tx.commit?;
Quantum Transactions with Entanglement
let tx = manager.begin;
let qtx = from_transaction;
// Mark keys as entangled - must be committed together
qtx.entangle?;
qtx.put?;
qtx.put?;
qtx.commit?; // Fails if not all entangled keys are written
Query API
use ;
let results = new
.key_prefix
.entry_type
.order_by
.limit
.execute?;
for entry in results.iter
Indexing
use ;
let manager = new;
// Hash index for exact lookups
manager.add_index?;
// B-tree index for range queries
manager.add_index?;
// Quantum index for Grover search
manager.add_index?;
Comparison with Classical Databases
| Aspect | Classical (RocksDB/PostgreSQL) | QDB |
|---|---|---|
| Storage | O(N) | O(n χ²) via MPS |
| Search | O(log N) indexed, O(N) scan | O(√N) Grover |
| Error Correction | Checksums | Golay [23,12,7] |
| Quantum States | Not supported | Native .qft format |
| Entanglement | N/A | Transaction groups |
LogosQ Integration
MPS Bridge Pattern
// Complete LogosQ → qft-rs → qdb-rs data flow
use ;
use UCCSD;
use ;
use *;
// 1. Run VQE in LogosQ
let hamiltonian = from_molecule;
let ansatz = UCCSDnew;
let solver = new;
let result = solver.run?;
// 2. Convert MPS state to QftFile
let mps = result.final_state;
let qft = new
.bond_dimension
.golay
.truncation_threshold
.metadata
.metadata
.metadata
.build?;
// Copy amplitudes from MPS
let amplitudes = mps.to_state_vector;
qft.set_amplitudes?;
// 3. Store in QDB
let db = QDBnew;
db.put_quantum?;
// 4. Later retrieval
let loaded = db.get_quantum?.unwrap;
println!;
Entanglement Transaction Semantics
Quantum transactions extend classical ACID with entanglement groups:
// Entangled keys represent correlated quantum states
// They MUST be committed atomically - partial writes fail
let qtx = from_transaction;
// Mark Alice and Bob's qubits as entangled
qtx.entangle?;
// Both must be written
qtx.put?;
qtx.put?;
// Commit succeeds only if ALL entangled keys are present
qtx.commit?;
Entanglement Representation: Entangled keys share logical correlation tracked in the transaction's write set. On commit, the transaction verifies all members of each entanglement group are present. This models quantum non-locality constraints where measuring one qubit affects its entangled partner.
Failure Model: If any entangled key is missing at commit time, the entire transaction rolls back. This prevents inconsistent states where only part of an entangled system is persisted.
Grover Search Implementation
The GroverSearch implements quantum-inspired amplitude amplification:
// Oracle marks target states, diffusion amplifies their probability
let search = new;
// Optimal iterations: π/4 * √N
let candidates = search.search?;
Complexity: O(√N) vs O(N) classical linear scan
Circuit Depth: ~O(√N) Grover iterations, each with oracle + diffusion
Measurement: Returns indices with highest amplitude after amplification
Radiation Hardening (Space Applications)
use QdbConfig;
let config = QdbConfig ;
let db = QDBwith_config;
Benchmarks
| Operation | N=1000 | N=10000 | N=100000 |
|---|---|---|---|
| Put (classical) | 0.8ms | 8ms | 85ms |
| Get (classical) | 0.1ms | 0.1ms | 0.1ms |
| Put (4-qubit) | 1.2ms | 12ms | 125ms |
| Get (4-qubit) | 0.3ms | 0.3ms | 0.3ms |
| Grover search | 2ms | 6ms | 20ms |
| Linear scan | 1ms | 10ms | 100ms |
Benchmarks on Apple M2, MemoryBackend, χ=64
Run benchmarks: cargo bench -p qdb-rs
Examples
Documentation
- Entanglement Semantics - Formal specification of entanglement groups
- Radiation Hardening - SEU mitigation and space deployment guide
Roadmap
v0.2 (Q2 2026)
- Distributed sharding with 2PC for entanglement groups
- Async backend trait (
AsyncBackend) - Query planner with cost-based optimization
- Index::quantum with precomputed Grover oracles
v1.0 (Q4 2026)
- Production-ready stability
- Full LogosQ MPS bridge (
QftFile::from_mps,to_mps) - Quantum hardware backend via logosq-hardware-integrator
- Comprehensive test suite (>90% coverage)
v2.0 (2027)
- PEPS/MERA tensor network support
- Quantum memory backend (trapped ions, superconducting)
- Cross-database entanglement routing
- Quantum consensus for Byzantine fault tolerance
License
MIT OR Apache-2.0
References
- Grover, L. K. (1996). "A fast quantum mechanical algorithm for database search." Proceedings of STOC.
- Peruzzo, A., et al. (2014). "A variational eigenvalue solver on a photonic quantum processor." Nature Communications, 5, 4213.
- LogosQ Paper (2025). arXiv:2512.23183v2. "LogosQ: Compile-Time Safe Quantum Simulation in Rust."
- QFT Specification v1.2.0 - MACROHARD Quantum OS
Contributing
See CONTRIBUTING.md for guidelines.
Acknowledgments
- LogosQ team for MPS backend and variational optimization
- QFT specification contributors
- Redox-QCOS ecosystem developers