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
Expected behavior
When creating a circuit with the ryy gate in Qiskit and exporting it to QASM with BQSKit, the generated QASM file should include a definition of the ryy gate.
Actual behavior
The generated QASM file does not include a definition of the ryy gate. When trying to read the generated QASM file with Qiskit or Pytket, an error is raised because the ryy gate is not defined.
Additional information
The ryy gate is not a standard gate and is not present in the qelib1.inc file. Thus, I would expect that the ryy gate is defined in the QASM file.
Source code
frombqskit.extimportqiskit_to_bqskitfromqiskit.qasm2importdumps, loadsfromqiskitimportQuantumCircuit, QuantumRegister, ClassicalRegisterqc=QuantumCircuit(2)
qc.ryy(0.1, 0, 1)
# Export with Qiskitqasm=dumps(qc)
print("-"*4)
print("Exported by Qiskit")
print(qasm)
# Export with BQSKitbqskit_circ=qiskit_to_bqskit(qc)
bqskit_circ.save("bqskit.qasm")
withopen("bqskit.qasm", "r") asf:
qasm_str_from_bqskit=f.read()
print("-"*4)
print("Exported by BQSKit")
print(qasm_str_from_bqskit)
# ----# Exported by Qiskit# OPENQASM 2.0;# include "qelib1.inc";# gate ryy(param0) q0,q1 { rx(pi/2) q0; rx(pi/2) q1; cx q0,q1; rz(param0) q1; cx q0,q1; rx(-pi/2) q0; rx(-pi/2) q1; }# qreg q[2];# ryy(0.1) q[0],q[1];# ----# Exported by BQSKit# OPENQASM 2.0;# include "qelib1.inc";# qreg q[2];# ryy(0.1) q[0], q[1];
Tracebacks
When reading the generated QASM file with Qiskit:
fromqiskitimportqasm2qiskit_read_back=loads(qasm_str_from_bqskit)
# QASM2ParseError: "<input>:4,0: 'ryy' is not defined in this scope"
When reading the generated QASM file with Pytket:
frompytket.qasmimportcircuit_from_qasm_strtket_circuit=circuit_from_qasm_str(qasm_str_from_bqskit)
# QASMParseError: Cannot parse gate of type: ryy Line:4.
Let me know if you need any additional information, thanks in advance
The text was updated successfully, but these errors were encountered:
MattePalte
changed the title
Bug: QASM export: custom gate definition ryy missing from generated QASM file
QASM export: custom gate definition ryy missing from generated QASM file
Oct 29, 2024
Environment
Expected behavior
When creating a circuit with the
ryy
gate in Qiskit and exporting it to QASM with BQSKit, the generated QASM file should include a definition of theryy
gate.Actual behavior
The generated QASM file does not include a definition of the
ryy
gate. When trying to read the generated QASM file with Qiskit or Pytket, an error is raised because theryy
gate is not defined.Additional information
The
ryy
gate is not a standard gate and is not present in the qelib1.inc file. Thus, I would expect that theryy
gate is defined in the QASM file.Source code
Tracebacks
When reading the generated QASM file with Qiskit:
When reading the generated QASM file with Pytket:
Let me know if you need any additional information, thanks in advance
The text was updated successfully, but these errors were encountered: