1
$\begingroup$

I'm trying to put together a demo using the Quantum Teleportation example provided by qiskit. The quantum circuit runs as intended when it's initialized to the state $|0\rangle$, and the measured result clearly sees the qubit $q_2$ taking on the state $|q_0\rangle$.

On the other hand, initializing $q_0$ to any other state will still yield $|0\rangle$ when measuring the state of $q_2$ at the end of the circuit, even after applying the inverse of the initialization operation as in this example. Is this correct?

Here's my code for the circuit:

# entangle two qubits
def create_bell_pair(qc: QuantumCircuit, a: int, b: int) -> None:
    qc.h(a)
    qc.cx(a, b)

def alice_gates(qc: QuantumCircuit, psi: int, a: int) -> None:
    qc.cx(psi, a)
    qc.h(psi)

def measure_and_send(qc: QuantumCircuit, a: int, b: int) -> None:
    qc.measure(a,0)
    qc.measure(b,1)

def bob_gates(qc: QuantumCircuit, qubit: int, crz: ClassicalRegister, crx: ClassicalRegister):
    qc.x(qubit).c_if(crx, 1) 
    qc.z(qubit).c_if(crz, 1) 


def teleportation_circuit(init_v: list[complex] = None) -> QuantumCircuit:
    qr = QuantumRegister(3, name="q")
    crz, crx = ClassicalRegister(1, name="crz"), ClassicalRegister(1, name="crx")
    qc = QuantumCircuit(qr, crz, crx)
    
    # initialize values
    psi = random_statevector(2)
    init_v = psi if init_v is None else init_v
    init_gate = Initialize(init_v)
    init_gate.label = "init gate"
    
    qc.append(init_gate, [0])
    qc.barrier()
    
    create_bell_pair(qc, 1, 2)
    qc.barrier()
    
    # send qubits to alice & bob
    alice_gates(qc, 0, 1)
    qc.barrier()
    
    # send classical bits to bob
    measure_and_send(qc, 0, 1)
    qc.barrier()
    
    # bob receives the classical bits 
    bob_gates(qc, 2, crz, crx)
    
    # bob reverse the initialization gate
    inverse_init_gate = init_gate.gates_to_uncompute()
    qc.append(inverse_init_gate, [2])

    # place result into a classical gate
    cr_result = ClassicalRegister(1)
    qc.add_register(cr_result)
    qc.measure(2,2)

    return qc

Here's the circuit rendered as a drawing: Circuit when qc.draw() is cal

After running the above circuit with $q_0$ initialized to $|1\rangle$, I get the following counts:

{'0 0 0': 256, '0 0 1': 232, '0 1 0': 232, '0 1 1': 280}

The circuit above is initialized to state $|1\rangle$, but I still measure $q_2$ to be $|0\rangle$ when running it on IBM's simulators, as well as ibmq_lima.

Could someone please tell me what I'm doing wrong? Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

This is because of these lines of code:

    # bob reverse the initialization gate
    inverse_init_gate = init_gate.gates_to_uncompute()
    qc.append(inverse_init_gate, [2])

These two lines add the gates that set $q_2$ back to $|0\rangle$. Just remove them and the output should look like:

{'1 1 1': 266, '1 0 0': 261, '1 1 0': 240, '1 0 1': 257}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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