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
Right now, pyqasm.unroll() seems to be adding an include "stdgates.inc" statement to all programs, even if the original qasm program didn't have it. This is problematic when using together with a library that doesn't support "include" statements, e.g. Amazon Braket:
frombraket.circuitsimportCircuitfrombraket.circuits.serializationimportIRTypefrombraket.ir.openqasmimportProgramfrompyqasmimportdumps, loadsbk_bell=Circuit().h(0).cnot(0, 1).measure(0).measure(1)
qasm_str=bk_bell.to_ir(IRType.OPENQASM).sourceprogram=Program(source=qasm_str)
# Reconstruct the original Circuit from QASM string - this works as expectedcircuit=Circuit.from_ir(source=program.source, inputs=program.inputs)
module=loads(qasm_str)
module.unroll()
qasm_unrolled=dumps(module)
program_unrolled=Program(source=qasm_unrolled)
# Attempt to reconstruct a Circuit from the unrolled QASM string - this raises a FileNotFoundError# Error: FileNotFoundError: [Errno 2] No such file or directory: 'stdgates.inc'circuit_unrolled=Circuit.from_ir(source=program_unrolled.source, inputs=program_unrolled.inputs)
The include "stdgates.inc" statement should only be added to the unrolled qasm if it was present in the original, input program.
Another related issue, let's say I unroll a qasm string with 2 custom include statements:
Right now,
pyqasm.unroll()
seems to be adding aninclude "stdgates.inc"
statement to all programs, even if the original qasm program didn't have it. This is problematic when using together with a library that doesn't support "include" statements, e.g. Amazon Braket:The
include "stdgates.inc"
statement should only be added to the unrolled qasm if it was present in the original, input program.Another related issue, let's say I unroll a qasm string with 2 custom include statements:
Using
pyqasm.unroll()
all existing include statements are overwritten byinclude "stdgates.inc";
, which shouldn't happen.The text was updated successfully, but these errors were encountered: