I created a circuit in qiskit and then converted it into a QASM string. When I try to make a circuit out of the QASM string I get the error:
QasmError: "Cannot find gate definition for 'mcphase', line 3 file circuit.qasm"
I used the following code to convert a circuit into a QASM file:
qasm_file_name = "circuit.qasm"
main_circuit.qasm(formatted=True, filename=qasm_file_name)
Then I loaded the QASM string like so:
circuit = QuantumCircuit.from_qasm_file(qasm_file_name)
After this, I get the QASM error above.
I believe mcphase
gate was generated automatically during the conversion to QASM. It seems the mapping from a qiskit circuit to QASM string is not reversible. How this can be fixed?
This is a toy QASM file that produces the error.
OPENQASM 2.0;
include "qelib1.inc";
gate ccircuit_87_dg q0,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16,q17,q18,q19,q20 { cx q0,q4; cu(pi/2,0,pi,0) q0,q4; mcphase(pi/8) q0,q4; cu(pi/2,0,pi,0) q0,q6;}
This is a full qiskit version printout:
{'qiskit-terra': '0.22.2', 'qiskit-aer': '0.11.1', 'qiskit-ignis': '0.7.0', 'qiskit-ibmq-provider': '0.19.2', 'qiskit': '0.39.2', 'qiskit-nature': None, 'qiskit-finance': None, 'qiskit-optimization': None, 'qiskit-machine-learning': None}
Ubuntu 20.04.5 LTS
main_circuit
nor I can easily distill it to a toy problem, at least for now. $\endgroup$qiskit.__qiskit_version__
. Also, if you can't post the circuit, could you add the first few lines of circuit.qasm file? $\endgroup$