ruqu-algorithms
Production-ready quantum algorithms in Rust — VQE for chemistry, Grover's search, QAOA optimization, and Surface Code error correction.
Algorithms
| Algorithm | Use Case | Speedup |
|---|---|---|
| VQE | Molecular ground states, chemistry | Exponential for certain problems |
| Grover | Unstructured database search | O(√N) vs O(N) |
| QAOA | Combinatorial optimization (MaxCut) | Approximate quantum advantage |
| Surface Code | Quantum error correction | Fault-tolerant computation |
Installation
Variational Quantum Eigensolver (VQE)
Find ground state energies for molecular Hamiltonians:
use ;
// H2 molecule Hamiltonian (simplified)
let hamiltonian = from_pauli_strings;
// UCCSD ansatz for chemistry
let ansatz = uccsd;
let vqe = VQEnew;
let result = vqe.optimize?;
println!;
Grover's Search
Quadratic speedup for unstructured search:
use ;
// Search for |101⟩ in 3-qubit space
let oracle = from_target;
let grover = new;
let result = grover.search?;
println!; // 101
Optimal iterations: π/4 × √N for N items.
QAOA MaxCut
Approximate solutions to NP-hard graph problems:
use ;
// Define graph edges
let graph = from_edges;
let qaoa = QAOAnew;
let result = qaoa.optimize?;
println!;
println!;
Surface Code Error Correction
Topological quantum error correction for fault-tolerant computing:
use ;
let code = new; // 3x3 lattice
let decoder = mwpm; // Minimum-weight perfect matching
// Encode logical qubit
let logical_state = code.encode_logical_zero;
// Simulate noise and correct
let noisy = code.apply_noise;
let syndromes = code.measure_syndromes;
let corrected = decoder.correct?;
Benchmarks
| Algorithm | Qubits | Time | Hardware |
|---|---|---|---|
| VQE (H2) | 4 | 50ms/iteration | M2 |
| Grover (N=1024) | 10 | 15ms | M2 |
| QAOA (depth=3) | 8 | 100ms | M2 |
| Surface Code (d=3) | 17 | 5ms/round | M2 |
Related Crates
ruqu-core— Quantum circuit simulatorruqu-exotic— Experimental quantum-classical hybridsruqu-wasm— Run in browsers via WebAssembly
Documentation
- VQE Algorithm (ADR-QE-005)
- Grover's Search (ADR-QE-006)
- QAOA MaxCut (ADR-QE-007)
- Surface Code (ADR-QE-008)
License
MIT OR Apache-2.0