-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingmod: qasm2Relating to OpenQASM 2 import or exportRelating to OpenQASM 2 import or export
Description
Environment
- Qiskit Terra version: master
What is happening?
@omarcostahamido noticed that it is possible to create a custom instruction in a circuit and then export it as QASM2 code. The result is non-valid QASM2.
How can we reproduce the issue?
This is the example provided by @omarcostahamido in Slack:
qc = QuantumCircuit(2,2, name='bell')
qc.h(0)
qc.cx(0, 1)
qc.measure_all()
custom_gate = qc.to_instruction()
new_circ = QuantumCircuit(2,2)
new_circ.append(custom_gate, [0, 1],[0, 1])
print(new_circ)
print(new_circ.qasm())
┌───────┐
q_0: ┤0 ├
│ │
q_1: ┤1 ├
│ bell │
c_0: ╡0 ╞
│ │
c_1: ╡1 ╞
└───────┘
OPENQASM 2.0;
include "qelib1.inc";
gate bell q0,q1 { h q0; cx q0,q1; barrier q0,q1; measure q0; measure q1; }
qreg q[2];
creg c[2];
bell q[0],q[1],c[0],c[1];
What should happen?
When a custom instruction is part of a circuit, exporting that circuit as QASM2 code should raise an error.
Any suggestions?
No response
omarcostahamido
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmod: qasm2Relating to OpenQASM 2 import or exportRelating to OpenQASM 2 import or export