You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gphase emitted for QASM 2 modules: rzz/rxx unroll to a global phase QASM 2 cannot express #351
rzz and rxx decompose to a body containing a QuantumPhase node, which Qasm2Module emits as gphase(...). OpenQASM 2 has no global-phase syntax at all, so the unroller turns a legal qelib1 gate into output no QASM 2 parser accepts.
The same applies outside a conditional — rzz(0.3) q[0],q[1]; at top level unrolls to a gphase statement.
QuantumPhase is also absent from Qasm2Module._whitelist_statements, so a second filtering pass over an already-unrolled AST rejects it by AST class name. That is reachable today: remove_idle_qubits() and reverse_qubit_order() both reassign _statements = _unrolled_ast.statements, and unroll() has no re-entry guard, so reverse_qubit_order() followed by remove_idle_qubits() raises where it passes on main.
Sweeping ~45 qelib1/pyqasm gate shapes: every gate but rzz/rxx produces only QuantumGate nodes.
Suggested fix
Either the unroller should not emit gphase for a Qasm2Module (global phase is unobservable, so dropping it is semantically safe for a QASM 2 target), or _qasm_ast_to_str should fold/drop the node at serialization. Whichever is chosen, add QuantumPhase handling to _whitelist_statements so the re-filtering path stops depending on it being absent.
#339 adds an interim QuantumPhase-specific diagnostic in _filter_branch_body so the error names global phase and points at rzz/rxx, rather than reporting an AST class for a program the user wrote as rzz. That is a message fix only — the underlying gap is this issue.
Activity
review: hoist qop constant, name keywords, report global phase honestly
fix: reject barrier as an OpenQASM 2 conditional body (#339)
Merge branch 'main' into fix-qasm2-gphase [no ci]
fix: drop unroll-emitted global phase for QASM 2 targets (qBraid#358)