Qasm exporter fails with ECRGate
QasmError: "Duplicate declaration for gate 'rzx'
#7749
Labels
bug
Something isn't working
mod: qasm2
Relating to OpenQASM 2 import or export
status: duplicate
This issue already exists
Environment
What is happening?
The qasm exporter on a circuit with an
ECRGate
outputs an invalid QASM code which cannot be parsed back.How can we reproduce the issue?
Run this circuit:
Output
Read the QASM back:
Output
What should happen?
I would have expected the final qasm to define a "general"
rzx
gate and reuse it:Any suggestions?
The problem is in the
qasm()
function of theQuantumCircuit
, in particular it fails to convertecr
which has two identicalrzx
instructions. I noticed that by having twoRZXGate
directly in the circuit, gives a correct result (even if it seems a bit odd, given that the parametrization is not used):Maybe, as a quick workaround, we should add this part below within the function
_add_sub_instruction_to_existing_composite_circuits
so that the two rzx gates get two identifiers.https://github.com/Qiskit/qiskit-terra/blob/ee0d76052411230848ab2830c5741c14c2450439/qiskit/circuit/quantumcircuit.py#L1689-L1693
Insert it above this line:
https://github.com/Qiskit/qiskit-terra/blob/ee0d76052411230848ab2830c5741c14c2450439/qiskit/circuit/quantumcircuit.py#L4738
Although, the most elegant solution would be to actually get a parametrizable
rzx
Looking forward to hearing your feedback on this odd situation, thanks in advance
The text was updated successfully, but these errors were encountered: