Quantum Complete 2025
QuSim
Research-grade quantum circuit simulator
The problem
Understanding quantum computing deeply is hard without hands-on experimentation, but real hardware is scarce, noisy, and expensive - and most simulators hide the physics behind an API.
The approach
Built a modular simulator where each backend is swappable behind one interface, with first-class noise, entanglement, and error-correction tooling so the physics is visible, measurable, and debuggable.
QuSim is a quantum circuit simulator I built from scratch to understand quantum computing at a level textbooks don’t reach: every phase convention, every measurement collapse, every decoherence channel, implemented and inspectable.
backends
Rather than one monolithic simulator, QuSim exposes four backends behind a single Backend interface, each with different tradeoffs:
- Statevector - exact evolution of pure states in a 2ⁿ-dimensional Hilbert space.
- Density matrix - mixed states and open-system dynamics, the substrate for realistic noise.
- Stabilizer (Gottesman–Knill) - polynomial-time simulation of Clifford circuits, scaling to hundreds of qubits.
- Tensor-network - memory-efficient simulation of large, lightly-entangled systems.
noise and diagnostics
Gates are unitary matrices; noise is modeled with Kraus operators applied to the density matrix, so depolarizing, amplitude-damping, and dephasing channels are first-class. The simulator tracks von Neumann entropy and mutual information in real time, and runs automatic failure diagnostics that flag when a circuit has become noise-dominated rather than silently returning garbage.
# A Bell state, then measure the entanglement it creates
circuit = Circuit(2)
circuit.h(0) # Hadamard on qubit 0
circuit.cx(0, 1) # CNOT: 0 -> 1
result = simulator.run(circuit) # (|00⟩ + |11⟩) / √2
print(result.von_neumann_entropy()) # ~1.0 bit - maximally entangled
error correction
A dedicated sandbox implements syndrome extraction and decoding, so you can watch a logical qubit survive physical errors - the payoff of everything above, made visible.
performance
Through sparse matrix representations and Numba JIT compilation (a 10–50× speedup on gate application), the statevector backend handles circuits up to ~25 qubits on a laptop - enough for most educational and many research scenarios - while the stabilizer backend goes much further for Clifford circuits.
why I built it
I wanted to understand quantum computing more deeply than reading allowed. Building a simulator forced me to confront every detail I would otherwise have hand-waved. The tool I built for myself turned into something genuinely useful for exploring quantum algorithms and noise.
What I took away
- Sparse representations and JIT compilation make ~25-qubit statevector simulation tractable on consumer hardware.
- The gap between the math and a numerically stable implementation is where the real understanding lives - phase conventions, measurement collapse, decoherence.
- A stabilizer backend turns exponential Clifford circuits into polynomial ones; picking the right backend per circuit matters more than raw speed.
0 comments
Loading…