Project — Build a Small Quantum Simulator from Scratch
Goal. A pure-numpy state-vector simulator with a text circuit front end, faster than naive kron-multiplication by orders of magnitude, tested against both hand-computed answers and Qiskit.
Deliverables.
qsim/package:dense.py(state-vector engine, tensordot-based),sparse.py(dict-based),parser.py,sampling.py,__init__.py.- Gate set: H, X, Y, Z, S, T, RX/RY/RZ(θ), CX, CZ, SWAP, M (measurement), plus arbitrary 1q unitary.
- CLI:
python -m qsim circuit.txt --shots 1024 --seed 7→ histogram;--method dense|sparse. - Test suite (
test_qsim.py): differential tests vs. naive kron implementation (n≤8); vs. Qiskit Aer same-seed distributions (n≤10); property tests (unitarity, ancilla cleanliness); performance regression markers. - Benchmark report (
BENCHMARK.md): time-per-gate and memory vs. n for your engine and Aer, one figure each.
Milestones.
- M1: single-qubit gates correct (17.3–17.4), tested against hand matrices.
- M2: CX/CZ/SWAP working (17.5), Bell state distribution 50/50 verified.
- M3: tensordot rewrite (17.7) passing all M1–M2 tests, ≥100× speedup at n=20.
- M4: parser + CLI + sampling (17.8–17.10).
- M5: sparse engine agreeing with dense on 5+ circuits (17.13).
- M6 (stretch): stabilizer engine via your own tableau or
stim(17.14).
Acceptance criteria. All tests green; n=26 gate apply < 1 s; Bell, GHZ (n=8), QFT (n=4) distributions match Aer within 2σ at 4096 shots; every module has a docstring stating its complexity in n.