Qnect 🔗
Quantum computing using Rust: build, simulate, and verify quantum circuits.
No config files. No magic. Just quantum.
use create;
async
Features
- 🚀 Fast - Pure Rust performance, no Python overhead
- 🔒 Type-safe - If it compiles, it runs
- 📈 Scalable - Same API works for 2 or 200 qubits
- 🌐 Network-ready - Built for distributed quantum computing
- 📊 Visual Circuits - See what you're building with ASCII diagrams
- 🎯 Zero config - No JSON files, no hidden mappings
- 🛠️ Extensible - Swap backends without changing code
Installation
[]
= "0.1"
= { = "1", = ["full"] }
= "0.8" # For quantum algorithms
# Requires Rust 1.70+ (for stable async traits)
Quick Start
Create a Bell State
let mut q = create.with_qubits.build?;
q.h.await?;
q.cnot.await?;
// Measurements are perfectly correlated
let m0 = q.measure.await?;
let m1 = q.measure.await?;
assert_eq!; // Always both 0 or both 1
Visualize Your Circuits
let mut q = create.with_qubits.build?.with_recording;
q.h.await?;
q.cnot.await?;
q.cnot.await?;
q.print_circuit;
// Output:
// q0: ┤H├─┤●├─┤●├─
// q1: ─────┤⊕├─┤│├─
// q2: ─────────┤⊕├─
Scale to N-qubit GHZ States
// The SAME code pattern works for any number of qubits
let n = 10;
let mut q = create.with_qubits.build?;
q.h.await?;
for i in 1..n
// Created |0000000000⟩ + |1111111111⟩
Quantum Teleportation
let mut q = create.with_qubits.build?;
// Alice prepares qubit 0 in state |ψ⟩
q.ry.await?;
// Alice and Bob share entanglement
q.create_bell_pair.await?;
// Teleportation protocol
q.cnot.await?;
q.h.await?;
let = ;
// Bob's corrections
if m1 == 1
if m0 == 1
// Qubit 2 now contains |ψ⟩!
Quantum Key Distribution (BB84)
use Rng;
// Create information-theoretically secure keys
let mut rng = thread_rng;
let mut shared_key = Vecnew;
for _ in 0..100
Clean Architecture
Core Components
🎯 QuantumSystem
The main API - clean, minimal, and async:
🔌 QuantumBackend Trait
Swap backends without changing your code:
📊 StateVectorBackend
Exact quantum simulation with pure Rust:
- No external dependencies
- Optimized gate operations
- Scales to ~30 qubits
🌐 QuantumNetwork
Distributed quantum computing made simple:
let mut network = new;
network.add_node;
network.add_node;
let = network.create_epr_pair?;
Clean Error Handling
match q.cnot.await
Complete Gate Set
All the gates you need, with consistent naming:
Single-qubit gates:
h()- Hadamardx(),y(),z()- Pauli gatess(),t()- Phase gatesrx(),ry(),rz()- Rotation gates
Two-qubit gates:
cnot()- Controlled-NOTcz()- Controlled-Zswap()- SWAP gatecy()- Controlled-Y
Examples
See Qnect in action:
# List all available examples
# Correctness verification
# Basic quantum
# Algorithms
# Cryptography
# All gates reference
🔬 Correctness Verification
Qnect implements quantum mechanics correctly. Run our comprehensive verification:
This runs five fundamental quantum tests with visual circuit diagrams:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1) CHSH (Bell inequality) — compute S with 95% CI
Classical bound: S ≤ 2; Quantum max: 2√2 ≈ 2.828
CHSH Test Circuit:
q0: ┤H├─┤●├────┤H├┤M├────
q1: ───┤⊕├─┤Ry├──────┤M├
S ≈ 2.619 (95% CI [2.591, 2.646]) → Violation observed!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Bell Inequality Violation - Reproduces quantum predictions beyond classical limits ✅ Phase Kickback - Demonstrates quantum information flow ✅ Interference Patterns - Shows wave-particle duality ✅ GHZ Correlations - Verifies multi-qubit entanglement ✅ Teleportation Fidelity - Confirms quantum state transfer
Why Qnect?
Built for Clarity - The Qnect way
Qnect prioritizes simplicity and correctness:
// Everything you need in one line
let mut q = create.with_qubits.build?;
// Clear, explicit operations
q.h.await?;
q.cnot.await?;
// Type safety catches errors at compile time
// q.cnot(0, 10).await?; // Won't compile - saves debugging time!
Design Principles
- Explicit over implicit - You see exactly what's happening
- Type-safe by default - Rust's compiler is your friend
- Minimal API surface - One clear way to do things
- Zero configuration - Start coding quantum circuits immediately
- Async-first - Ready for distributed quantum computing
Focus on Fundamentals
Qnect helps you understand quantum computing by:
- Providing clear visual circuit representations
- Including comprehensive correctness tests
- Offering working examples of real quantum algorithms
Performance
- State Vector Backend: Exact simulation up to ~30 qubits on modern hardware
- Memory: ~16GB RAM for 30 qubits (2^30 complex amplitudes)
- Speed: Optimized gate operations, multi-threaded where possible
- Coming Soon: Stabilizer backend for 1000+ qubit Clifford circuits
Pure Rust performance with no Python overhead.
Roadmap
✅ Completed
- State vector simulator with all standard gates
- Async/await API
- Backend trait system
- Circuit visualization
- Quantum networking
- BB84 Quantum Key Distribution
- Comprehensive correctness tests
🚧 In Progress
- Stabilizer backend (Clifford circuits to 1000s of qubits)
- OpenQASM import/export
- Noise models
🔮 Future
- Tensor network backend
- Hardware backends (IBMQ, IonQ)
- Distributed quantum operations
- Circuit optimization
Contributing
We welcome contributions! Areas we're excited about:
- 🧮 Backend implementations - Stabilizer, tensor networks
- 🔧 Quantum algorithms - Grover, Shor, VQE, QAOA
- 📊 Benchmarks - Show us where we can improve
- 📖 Documentation - Help others learn quantum + Rust
Testing
# Run all tests
# Run verification suite
License
MIT OR Apache-2.0 (your choice)
Remember: In quantum computing, the hardest part shouldn't be the framework.
Qnect - Where quantum meets Rust. 🦀⚛️