The Quantum Engineer

66. Project 1 — Quantum Simulator

Build: state vector, gate engine, measurement, sampling, circuit parser. (Chapter 17 is the full design document — this page is the contract.)

Specification. A Python package qsim with: (1) a state-vector core holding complex amplitudes for n qubits; (2) a gate engine applying H, X, Y, Z, S, T, RX/RY/RZ(θ), CX, CZ, SWAP, and arbitrary 1-qubit unitaries, implemented with tensor contraction (tensordot/moveaxis) — not kron-per-gate; (3) measurement: full-register sampling from |amplitudes|², plus single-qubit mid-circuit measurement with renormalization; (4) a batch sampler with seeded reproducibility; (5) a text circuit parser (H 0, CX 0 1, RZ 1.5708 2, M 0 1) with validation; (6) a CLI: python -m qsim circuit.txt --shots 4096 --seed 42 printing a histogram.

Milestones. M1: single-qubit gates correct (test: each gate's application matches its 2×2 matrix on hand-worked examples). M2: CX, CZ, SWAP; Bell state |Φ⁺⟩ gives 50/50 on 4096 shots (±2σ). M3: tensor-contraction rewrite passes all M1–M2 tests; ≥100× faster than kron version at n=20. M4: parser + CLI + seeded sampling. M5: GHZ-n (n=8) and QFT-4 distributions match Aer same-seed.

Acceptance criteria. Bell, GHZ-8, QFT-4 match Qiskit Aer within statistical bounds at 4096 shots; n=26 gate application < 1 s on a laptop; all tests pass from a clean clone (pip install -e . && pytest); README states complexity (time O(2ⁿ) per gate, memory 16·2ⁿ bytes) with a benchmark table you measured, not quoted.

What it proves. You understand the circuit model at the implementation level — Part VI is no longer notation. Estimated effort: 2–3 weekends.