The scaffolding is gone. The hard math is in.
Today we released QuantRS2 0.1.3 — the release where a great deal of placeholder and approximate machinery becomes real, verified quantum math, shipped alongside a major robustness pass that takes panics out of the production paths.
No C. No Fortran. No CUDA toolkit. No Python runtime. QuantRS2 is a comprehensive, modular, pure-Rust quantum computing framework — simulation, algorithm development, and hardware interaction — and a Rust-native alternative to Qiskit, Cirq, PennyLane, and the C++/CUDA simulators like Stim and cuQuantum. Even SymEngine’s C++ symbolic core is replaced here by quantrs2-symengine-pure, a 100%-Rust SymEngine substitute. The result compiles to a single static binary, or to WASM, with no glue layer to babysit.
Why QuantRS2 0.1.3 is a game changer
The incumbent quantum stacks are Python orchestration over C++/CUDA kernels, and they ship plenty of routines that are honest about being approximate or placeholder until someone fills them in. QuantRS2 0.1.3 fills a lot of those in — and does it in one type-safe language all the way down. Concretely:
- Real two-qubit decompositions. KAK / Cartan decomposition now uses a genuine QR-iteration eigensolver (Householder tridiagonalization + Givens rotations) to extract interaction coefficients, and ZYZ synthesis ships corrected theta formulas — a previously-ignored test now passes.
- Exact gradients, not finite differences. The parameter-shift rule is wired through both VQE and the variational rotation layers, giving analytical gradients instead of noisy numerical estimates.
- ZX-calculus that actually rewrites. Real Clifford spider rules (spider fusion, Hadamard cancellation, identity removal) plus tableau reduction with a convergence loop.
- SABRE routing with real swap scoring. Coupling-map distance-based scoring replaces the old uniform scoring, so circuits map onto hardware with fewer SWAPs.
- MPS / tensor-network compression. SVD-truncated bond-dimension compression for both
TensorNetworkandMatrixProductState. - ML-driven circuit optimization. Q-learning, genetic-algorithm, and feedforward neural-network policies for gate-sequence optimization.
- A real QPE fix. Quantum counting was applying
U^(N·2^target)instead ofU^(2^target)per control qubit; that controlled-U power bug is fixed. - A no-panic robustness pass. Roughly 210
unwrap()calls were removed from production code in favor of typed error propagation.
This all sits on a substantial base: 4,707 tests passing (0 failures, 69 skipped) across 777,061 lines of Rust.
Technical Deep Dive
Core synthesis & math. The core crate is where most of the placeholder-to-real work happened. cartan.rs performs KAK decomposition through a Householder + Givens QR eigensolver; synthesis.rs fixes the ZYZ theta formulas; adiabatic.rs computes ground-state energy with inverse power iteration, deflation, and Rayleigh-quotient refinement; and holonomic.rs now runs with graceful convergence handling. The quantum-walk eigensolvers were rebuilt entirely on Golub-Reinsch QR iteration, Householder tridiagonalization, Sturm-sequence bisection, and Wilkinson-shift implicit QR for tridiagonal eigenproblems — verified against known spectra (P4 eigenvalues {0, 2−√2, 2, 2+√2}, K4 Fiedler value 4.0).
Circuit compilation. The circuit crate gained SABRE routing with coupling-map distance scoring, ASAP scheduling via Kahn topological sort, greedy noise-aware qubit remapping, and dynamical-decoupling insertion (XY4, CPMG, XY8). Peephole/template matching now handles 2-gate cancellations (H-H, X-X) and a 3-gate pattern (H-X-H → Z). Tensor-network support added TensorNetwork::compress via SVD truncation and MatrixProductState::from_circuit / ::compress, and the DistributedExecutor gained real job tracking (JobRecord + registry, with submit_job / get_job_status / cancel_job / get_results state transitions).
Variational & QML stack. Beyond parameter-shift gradients, the QML layer adds Möttönen-style amplitude encoding (recursive binary-tree multiplexor for arbitrary state preparation) and correct IQP ZZ interactions, e^{-iθ/2 Z⊗Z} built as CNOT·(I⊗RZ(θ))·CNOT. VQE’s set_parameters now actually rebuilds parameterized gates with updated angles via ParameterizedGateRecord tracking. Symbolic evaluation is wired to the pure-Rust quantrs2-symengine-pure backend (evaluate, evaluate_complex, free_symbols, is_constant, substitute).
Python & error mitigation. The py crate migrated from PyO3 0.22 to 0.26 (Python::attach replaces with_gil; Py<PyAny> replaces PyObject) and added error-mitigation bindings: quasi-probability decomposition (PEC, returning 1+3n terms), virtual distillation via a SWAP-test circuit (M=2 copies), and symmetry verification (Z2/parity, U(1)/particle-number, time-reversal). On the simulation side, the sim crate’s quantum-supremacy path got a real inline statevector apply_gate_to_state and inverse-CDF sample_from_amplitudes, replacing zero-filled placeholders.
As engineering discipline, this release also kept the no-unwrap robustness work moving and honored the COOLJAPAN 2000-line policy: several large files were split into module directories (quantrs2/src/lib.rs, py/src/lib.rs, circuit/src/builder.rs, core/src/quantum_walk.rs, plus splits across ml/, device/, and anneal/).
Getting Started
cargo add quantrs2-core quantrs2-circuit quantrs2-sim
A Bell state from scratch:
use quantrs2_circuit::builder::Circuit;
use quantrs2_sim::statevector::StateVectorSimulator;
fn main() {
let mut circuit = Circuit::<2>::new();
circuit.h(0).unwrap()
.cnot(0, 1).unwrap();
let simulator = StateVectorSimulator::new();
let result = circuit.run(simulator).unwrap();
for (i, prob) in result.probabilities().iter().enumerate() {
let bits = format!("{:02b}", i);
println!("|{}⟩: {:.6}", bits, prob);
}
}
Note the const-generic Circuit::<2> — qubit counts are checked at compile time.
What’s New in 0.1.3
- Core decompositions made real: KAK/Cartan (QR eigensolver), ZYZ (corrected formulas), holonomic synthesis, and adiabatic ground-state energy via inverse power iteration.
- QML encodings & exact gradients: Möttönen amplitude encoding, correct IQP ZZ interactions, and parameter-shift gradients for variational rotation layers.
- ZX-calculus & quantum-walk eigensolvers: Clifford spider rewrites with a convergence loop; tridiagonal eigenproblems via Golub-Reinsch / Sturm bisection / Wilkinson-shift QR.
- Compilation upgrades: SABRE coupling-map routing, ASAP/Kahn scheduling, XY4/CPMG/XY8 dynamical decoupling, and peephole templates.
- Tensor networks: SVD-based
TensorNetworkandMatrixProductStatecompression, plus MPS construction from circuits. - ML circuit optimizers: Q-learning, genetic-algorithm, and neural-network policies for gate-sequence optimization.
- Distributed job tracking: real submit / status / cancel / results lifecycle in
DistributedExecutor. - Quantum-supremacy sampling: inline statevector application and inverse-CDF bitstring sampling.
- Tytan improvements: real constraint-violation counting in sensitivity analysis, SymEngine-based
get_nbit_value, a proper simulated-annealing HOBO solver (Metropolis + geometric cooling), and mean-field Hamiltonian evaluation. - Python modernization: PyO3 0.22 → 0.26, plus error-mitigation bindings (PEC, virtual distillation, symmetry verification).
- Robustness & hygiene: ~210
unwrap()calls removed in favor of typed errors, and large files split below the 2000-line limit.
Tips
- Train VQE with exact gradients. Use the parameter-shift rule in
vqe.rsinstead of finite differences — analytical gradients converge faster and don’t suffer numerical noise. - Compile to your hardware’s coupling map. Run SABRE routing so two-qubit gates land on connected qubits with fewer inserted SWAPs.
- Fight decoherence with dynamical decoupling. Insert XY4, CPMG, or XY8 sequences through the noise-aware optimizer for idle-qubit protection.
- Compress low-entanglement states. Use
MatrixProductState::compressand tune the bond dimension / tolerance to trade fidelity for memory. - Mitigate error from Python. The new bindings expose PEC, virtual distillation, and symmetry verification (Z2, U(1), time-reversal) directly.
- Handle the
Result. Production code now returns typed errors instead of panicking on unexpectedNone/Err— propagate them with?rather than re-introducingunwrap().
This is the foundation
QuantRS2 is built on the SciRS2 scientific-computing stack — scirs2-core supplies arrays, linear algebra, FFT, parallelism, and GPU primitives. Around it sit NumRS2 for numerics, OptiRS powering the VQE/QAOA optimizers, and OxiFFT and OxiZ (SMT) where transforms and symbolic reasoning are needed. The same pure-Rust ecosystem also carries ML tooling — ToRSh, SkleaRS, and TrustformeRS — so a quantum-classical hybrid workflow never has to leave the language.
Repository: https://github.com/cool-japan/quantrs
Star the repo if a pure-Rust quantum stack — with real decompositions, exact gradients, and no panics in the hot path — is what you’ve been waiting for.
Pure Rust quantum computing is here — fast, safe, and sovereign.
— KitaSan at COOLJAPAN OÜ March 27, 2026