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
dumps() prints the original program when unroll() leaves at most one statement #493
dumps() (through QasmModule.__str__) prints the unrolled AST only when it has more than one statement (if len(self._unrolled_ast.statements) > 1, modules/base.py). A program that unrolls down to just its register declaration therefore comes back as the original source, custom gate definitions and all.
frompyqasmimportloads, dumpsm=loads("OPENQASM 3.0;\ngate g a { }\nqubit[1] q;\ng q[0];")
m.unroll()
[type(s).__name__forsinm.unrolled_ast.statements] # ['QubitDeclaration']dumps(m) # 'OPENQASM 3.0;\ngate g a {\n}\nqubit[1] q;\ng q[0];\n'
The caller asked for the unrolled program and gets output that still has gate definitions and calls to them. With #459, ctrl @ x on a custom identity x hits the same thing. A tool that unrolls first so that every custom gate is gone, and then imports the result into Qiskit, gets the custom x back, and Qiskit's ctrl @ turns it into a real CX.
__str__ could track whether unroll() has run instead of counting statements.
Activity