The OpenQASM language is the standard for exchange circuits among several quantum computing tools. You can use to move your Qiskit circuit to the IBM Quantum Composer.
print(circuit.qasm())
OPENQASM 2.0;
include "qelib1.inc";
gate multiplex1_reverse_dg q0 { ry(pi) q0; }
...
You can take the output and paste it in the OpenQASM 2.0 box in IBM Quantum Composer.
Note: At the moment, there is an issue in Qiskit that QASM-exports a circuit with initialize
instructions as "gates". For your specific case, you need to do decompose
first:
print(circuit.decompose().qasm())
Detailed explanation of initialize
: Qiskit initialize
is a reset
followed by a state preparation. Take the following example:
circuit = QuantumCircuit(1)
circuit.initialize([0,1], 0)
print(circuit.decompose().qasm())
OPENQASM 2.0;
include "qelib1.inc";
gate multiplex1_reverse_dg q0 { ry(pi) q0; } #3
gate disentangler_dg q0 { multiplex1_reverse_dg q0; }
gate state_preparation(param0,param1) q0 { disentangler_dg q0; }
qreg q[1];
reset q[0]; #1
state_preparation(0,1) q[0]; #2
In #1
, the reset
, followed by state_preparation
in #2
. After some nested calling, the standard ry
is called in #3
. In this case, circuit.initialize([0,1], 0)
is equivalent to reset q0[0]; ry(pi) q0[0]
.