3
$\begingroup$

I can't seem to find anything, but this seems like something that should be possible.

$\endgroup$
3
$\begingroup$

You can convert a qiskit circuit to QASM using circuit.qasm(). You can copy this and then there's an "Import OpenQASM" button on the initial circuit composer page:

enter image description here

and you can paste the QASM into a tab of the composer itself:

enter image description here

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ I am a little bit confused. I think that the question was on code in Qiskit, not QASM. $\endgroup$ – Martin Vesely Dec 3 '19 at 6:19
  • 2
    $\begingroup$ IBM Q Experience circuit composer takes OpenQASM code, not Qiskit code. $\endgroup$ – Junye Huang Dec 3 '19 at 11:33
  • $\begingroup$ Thank you, this is exactly what I was looking for! For anyone trying it, you have to do print(circuit.qasm()) if you want to be able to copy paste into the circuit editor. $\endgroup$ – ejw_art Dec 3 '19 at 19:16
1
$\begingroup$

Let's say, you've the Qiskit code for the circuit that you want to implement in Circuit Composer as shown below.

qr = QuantumRegister(3, name="q")
crz, crx = ClassicalRegister(1, name="crz"), ClassicalRegister(1, name="crx")
qc = QuantumCircuit(qr, crz, crx)

qc.h(1) # Put qubit a into state |+>
qc.cx(1,2) # CNOT with a as control and b as target

Then use print(qc.qasm()) to get the circuit equivalent, which is as follows

OPENQASM 2.0;
include "qelib1.inc";

qreg q[3];
creg crz[1];
creg crx[1];

h q[1];
cx q[1],q[2];

You can run this code in QASM / Circuit Composer.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.