Skip to main content
KetQat

Appearance

Definition · intermediate

Peephole and template optimization of quantum circuits

Circuit optimization by local rewriting. A rule replaces a small subcircuit, found up to gate commutation, by an equivalent cheaper one; templates are identity circuits whose parts can be swapped for their inverse complements.

Established definitionMachine-checkedUpdated 2026-12-01 · last verified 2026-12-01

AI-assisted text, machine-checked, not yet reviewed by a person. Citations resolve and an automated pass compared the statements with the cited sources. That is not peer review; check the sources for anything you depend on.

A rewrite rule is a pair of circuits (L,R)(L, R) on the same qubits with UL=URU_L = U_R (up to phase) and cost(R)<cost(L)\mathrm{cost}(R) < \mathrm{cost}(L). A peephole optimizer repeatedly finds an occurrence of some LL in the circuit, where an occurrence may be spread out in time provided the gates between its parts commute past them, and replaces it with RR. Typical rules: cancel GG−1G G^{-1} (for example two adjacent CNOTs or Hadamards on the same qubits); merge Rz(α)Rz(β)=Rz(α+β)R_z(\alpha) R_z(\beta) = R_z(\alpha+\beta), moving RzR_z through CNOT controls; and resynthesise a maximal two-qubit block with the three-CNOT construction when that is cheaper.

A template is a circuit T=T1T2T = T_1 T_2 implementing the identity. Any occurrence of T1T_1 (with more than half of TT's gates) can be replaced by T2−1T_2^{-1}, which is shorter (Maslov et al.). Finding all maximal matches of a pattern in a circuit modulo commutation is itself an algorithmic problem; Iten et al. give an exact algorithm that is polynomial in the circuit size for a fixed pattern size. Rule-based optimizers with continuous rotation angles, phase-polynomial resynthesis and floating rotations are described by Nam et al..

Local rewriting always terminates when each step strictly lowers an integer cost, but it finds only local optima: the final circuit depends on the order in which rules are applied.

Holds when

  • Circuits are sequences of gates from a fixed library; equivalence means equality of the implemented unitaries, possibly up to a global phase.
Stated in

Open in the knowledge graph

Contributions about this record

Nobody has published a contribution about it yet.

Publish a result, reproduction or commentPropose a correction to this page

References

  1. D. Maslov, G. W. Dueck, D. M. Miller, C. Negrevergne (2008). Quantum Circuit Simplification and Level Compaction. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 27, 436-444. doi:10.1109/TCAD.2007.911334
  2. Yunseong Nam, Neil J. Ross, Yuan Su, … Dmitri Maslov (2018). Automated optimization of large quantum circuits with continuous parameters. npj Quantum Information 4, 23. doi:10.1038/s41534-018-0072-4arXiv:1710.07345
  3. Raban Iten, Romain Moyard, Tony Metger, … Stefan Woerner (2022). Exact and Practical Pattern Matching for Quantum Circuit Optimization. ACM Transactions on Quantum Computing 3, 1-41. doi:10.1145/3498325arXiv:1909.05270

Contributors

  • KetQat maintainers · @ketqatConceptualization; Supervision (CRediT roles)
  • Claude (AI drafting assistant)Writing, original draft (CRediT roles)

Review history

  1. Automated source check · Pass · 2026-12-01 · Independent automated verification pass (AI, not the drafting session)

    Rewrite-rule and template definitions checked (T = T1 T2 = I implies T1 = T2^-1, shorter when T1 holds more than half of T). Template-matching background and the claim that pattern matching modulo commutation finds all maximal matches in time polynomial in circuit size for fixed pattern size compared with Iten et al., arXiv 1909.05270 (ACM TQC 3, 2022), abstract and Sec. 1 (template definition after Maslov et al.). Nam et al., arXiv 1710.07345 (npj QI 4, 23, 2018) title and topic; Maslov et al. TCAD 27, 436 (2008) metadata on Crossref only (paywalled). All Crossref metadata match.

Revision history

  1. 2026-12-01Content release 2.1.0: 35 more topics, an independent source check of every record, intake hardening (#17)80537b7e

Current revision ae4dae01966a69ab. Source file knowledge/records/definition/peephole-optimization.md in the content repository (readable there once it is public).