zxcalc/pyzx

Python library for quantum circuit rewriting and optimisation using the ZX-calculus

What it solves

PyZX simplifies and optimizes large-scale quantum circuits. It addresses the challenge of reducing the complexity of quantum programs by converting them into a diagrammatic representation (ZX-calculus) where they can be automatically rewritten and simplified before being converted back into a circuit.

How it works

The tool uses the ZX-calculus, a graphical language where quantum operations are represented as tensor networks of "spiders" (Z-spiders and X-spiders). PyZX converts quantum circuits from formats like QASM, Quipper, or Quantomatic into these graphs, applies a set of rewrite rules—specifically those for the Clifford fragment—to reduce the graph to a pseudo-normal form, and then extracts a new, simplified circuit from the result.

Who it’s for

It is designed for quantum computing researchers and developers who need to optimize quantum circuits for better performance or visualization.

Highlights

  • Multi-format support: Reads and outputs circuits in QASM, QC, and QUIPPER formats.
  • Automated rewriting: Uses a complete set of rewrite rules for Clifford diagrams to simplify circuits.
  • Visualization: Supports rendering graphs via Matplotlib, Quantomatic, or TikZ for LaTeX.
  • Integration: Works as a Python module, a command-line tool, or within Jupyter notebooks.

Related

  • Project
  • Project
  • Project
  • Project
  • Project