ruqu-core
High-performance quantum circuit simulator in pure Rust — state-vector simulation with SIMD acceleration, noise models, and multi-threading support.
Features
- State-Vector Simulation — Complex128 amplitude representation for exact quantum state evolution
- Universal Gate Set — H, X, Y, Z, CNOT, CZ, Toffoli, Rx, Ry, Rz, Phase, SWAP, and custom unitaries
- Noise Models — Depolarizing, amplitude damping, phase damping, and custom Kraus operators
- SIMD Acceleration — AVX2/NEON vectorized gate application for 2-4x speedup
- Multi-Threading — Rayon-based parallelism for large qubit counts
- Measurement — Single-qubit, multi-qubit, and partial measurement with state collapse
- Circuit Optimization — Gate fusion, cancellation, and commutation rules
Installation
With optional features:
Quick Start
use ;
// Create a 3-qubit circuit
let mut circuit = new;
// Build a GHZ state: |000⟩ + |111⟩
circuit.h; // Hadamard on qubit 0
circuit.cnot; // CNOT: control=0, target=1
circuit.cnot; // CNOT: control=1, target=2
// Execute simulation
let simulator = new;
let state = simulator.run?;
// Measure all qubits
let result = state.measure_all;
println!; // Either 000 or 111
Quantum Gates
| Gate | Description | Matrix |
|---|---|---|
H |
Hadamard | Creates superposition |
X |
Pauli-X (NOT) | Bit flip |
Y |
Pauli-Y | Bit + phase flip |
Z |
Pauli-Z | Phase flip |
CNOT |
Controlled-NOT | Two-qubit entanglement |
CZ |
Controlled-Z | Controlled phase |
Rx(θ) |
X-rotation | Rotate around X-axis |
Ry(θ) |
Y-rotation | Rotate around Y-axis |
Rz(θ) |
Z-rotation | Rotate around Z-axis |
SWAP |
Swap qubits | Exchange qubit states |
Toffoli |
CCX | Three-qubit AND gate |
Performance
Benchmarks on Apple M2 (single-threaded):
| Qubits | Gates | Time |
|---|---|---|
| 10 | 100 | 0.3ms |
| 15 | 100 | 8ms |
| 20 | 100 | 250ms |
| 25 | 100 | 8s |
With --features parallel on 8 cores, 20+ qubits see 3-5x speedup.
Noise Simulation
use ;
let noise = new
.add_single_qubit // 1% error rate
.add_two_qubit; // 2% for CNOT
let noisy_state = simulator.run_noisy?;
Related Crates
ruqu-algorithms— VQE, Grover, QAOA, Surface Coderuqu-exotic— Quantum-classical hybrid algorithmsruqu-wasm— WebAssembly bindings
Architecture
Part of the RuVector ecosystem. See ADR-QE-001 for design decisions.
License
MIT OR Apache-2.0