Project — Build a Toy Quantum Compiler
Goal. An end-to-end compiler pipeline — parse → DAG IR → optimize → route to a coupling map → synthesize to a native gate set → benchmark — that measurably improves real circuits and is verifiably correct at every pass.
Deliverables.
qcc/package:parser.py(17.10 format + parameter expressions θ/2),dag.py(DAGCircuit: nodes, edges, topological iteration),passes/(cancel_inverse.py,commute.py,merge_rotations.py,route_sabre.py,direction_fix.py,euler_resynth.py),target.py(coupling map + gate set + per-gate error model),cost.py,benchmark.py.- Pipeline driver with pluggable pass list and per-pass stats (gates, depth, 2q-count, est. error).
- Test suite: per-pass
Operator-equivalence tests (correctness), differential tests vs Qiskittranspileon 10 circuits, property test "output unitary ≡ input unitary up to global phase" for the whole pipeline. REPORT.md: benchmarks on QFT-n4/5, Grover-3-qubit, 4-bit adder, GHZ chains — your pipeline vs Qiskit O0–O3, ≥20 seeds, medians + IQR, two figures.
Milestones.
- M1: parser + DAG + equivalence checking harness (the correctness foundation — build it first).
- M2: cancellation + rotation merging (46.4) passing equivalence tests, ≥10% gate reduction on QFT.
- M3: routing on a 7-qubit heavy-hex map with layout permutation tracking, measurements permuted correctly (46.2's classic bug — test it by name).
- M4: commutation + resynthesis (46.5–46.7), parity or better with Qiskit O1 on the corpus.
- M5: benchmark report with honest error bars (46.8).
Acceptance criteria. Pipeline output is unitary-equivalent to input on all tests; measured-layout histograms match expected permutations; report shows your compiler beating O0 and being honestly compared to O2/O3; every pass independently unit-testable via a documented interface.