Skip to content

Conversation

@dlyongemallo
Copy link
Contributor

Fixes #192 and #345.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for reset and measure instructions in the OpenQASM parser, addressing issues #192 and #345. The implementation introduces a new Reset gate class and extends the parser to handle both single-qubit and register-broadcast forms of these instructions.

Changes:

  • Added Reset gate class that models reset as post-selection followed by state preparation in ZX-diagrams
  • Extended QASM parser to handle reset instruction for single qubits and entire registers
  • Enhanced measure instruction to support register broadcast syntax (measure q -> c)
  • Added classical register tracking and automatic declaration in QASM output
  • Implemented graph conversion logic to handle reset as effect + state vertices

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyzx/circuit/gates.py Added Reset gate class with to_qasm, reposition, and equality methods; added to_qasm method for Measurement
pyzx/circuit/qasmparser.py Added parsing for reset and register-broadcast measure; added cregisters tracking
pyzx/circuit/graphparser.py Added circuit_to_graph logic for Reset (effect+state vertices); added graph_to_circuit detection of Reset vs InitAncilla
pyzx/circuit/init.py Added automatic classical register declaration inference from Measurement gates
tests/test_qasm.py Added comprehensive tests for reset and measure including QASM round-trips and graph conversions
tests/test_init_postselect.py Added unit tests for Reset gate functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dlyongemallo dlyongemallo force-pushed the 192-qasmparser_reset_measure branch from 6e7f0f1 to dc5e02b Compare February 6, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support reset and measure in qasmparser

1 participant