Fix QASM3 exporter unitary gate naming#16062
Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
jakelishman
left a comment
There was a problem hiding this comment.
This is not a correct fix, because the root fault is not in the exporter but in the importer. The data model of Qiskit is not violated until an Instruction called unitary that is not a UnitaryGate is constructed, and Qiskit is not the only source of OpenQASM files, so the fix cannot be to write out an OpenQASM file differently.
Summary
Rename exported OpenQASM 3 gate definitions that would otherwise use the bare symbol
unitary.Fixes #14310.
Root cause
The OpenQASM 3 exporter preserved the
UnitaryGatename when emitting a gate definition, so it produced output such as:gate unitary _gate_q_0 { ... } unitary q[0];Downstream consumers such as Qiskit Aer treat
unitaryas a special instruction name rather than a user-defined gate symbol, so the exported program could be misclassified and fail when reloaded.Fix
unitarytounitary_gatethrough the exporter symbol tableTests
PYTHONPATH=$PWD python -m unittest -v test.python.qasm3.test_exportPYTHONPATH=$PWD python -m black --check qiskit/qasm3/exporter.py test/python/qasm3/test_export.pyPYTHONPATH=$PWD python -m ruff check qiskit/qasm3/exporter.py test/python/qasm3/test_export.pyNotes or limitations
reno lintcould not be completed in this checkout because the local repository hits a Dulwich missing-object error while scanning note history (KeyError: b'09bcf1597b54b73fef724dc3f02a6fae8edbdf1f').AI/LLM disclosure