1
$\begingroup$

I'm trying to create the teleportation circuit in IBM Qiskit Circuit Composer.

OPENQASM 2.0;
include "qelib1.inc";

qreg q[3];
creg a[3];   // should be crz
creg b[4];   // should be crx

h q[1];
cx q[1],q[2];
barrier q; //[0];

cx q[0],q[1];
h q[0];
barrier q;

measure q[0] -> a[0];
measure q[1] -> b[0];
barrier q;

This gives me the following circuit till the 3rd measurement barrier. How do I add CRX and CRZ gates - to obtain the circuit as shown in the picture? Also, how to change the names of the classical registers from a3, b4 to crz and crx?

Teleportation Circuit

$\endgroup$
2
$\begingroup$

crx and crz are classical register. The gates CRX or CRZ mean that you apply the X gate on qubit 2 if the measurement on the classical register crx is a 1, that is if qubit 1 (q1) is in the $|1\rangle$ state; and you will apply the Z gate on qubit 2 if the classical register crz is 1.

This can be done in qiskit with c_if operation. You can see example of the teleportation code in Qiskit here: https://qiskit.org/textbook/ch-algorithms/teleportation.html



Anyway, if you want to use OPENQASM, then you can do it as follow:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[3];
creg crzz[3];   // since crz is already taken I use crzz instead
creg crxx[4];   // Again I use crxx instead of crx

h q[1];
cx q[1],q[2];
barrier q; //[0];

cx q[0],q[1];
h q[0];
barrier q;

measure q[0] -> crzz[0];
measure q[1] -> crxx[0];
barrier q;

if(crzz==1) z q[2];
if(crxx==1) x q[2]; 

Here is the image of the circuit when using Circuit_Composer option within IBMQ Experience environment.

enter image description here

$\endgroup$
3
  • $\begingroup$ thanks @KAJ226! Now, if I measure q2, I should get the same state as q0 right? $\endgroup$ – Van Peer Oct 25 '20 at 7:11
  • $\begingroup$ Yes. The idea is the state of $q0$ has teleported to $q2$. If $q0$ was in the state $|1\rangle$ then measurement on $q2$ will only have value 1. $\endgroup$ – KAJ226 Oct 25 '20 at 17:33
  • 1
    $\begingroup$ But I also should point out that the condition operations we defined above is not executable on current hardware, as far as I know of. Therefore you can only do this on simulator. To run the teleportation on hardware, you need to make a little modification. See here: qiskit.org/textbook/ch-algorithms/teleportation.html#real_qc $\endgroup$ – KAJ226 Oct 25 '20 at 17:36

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.