Skip to content

Non-ideomatic teleportation algorithm, no c_if not used #52

@MattePalte

Description

@MattePalte

Environment

  • qiskit.version: 0.45.2
  • Python version: 3.10.12
  • Operating system: Ubuntu 20.04

What is happening?

In the Python file teleportation.py the circuit first measures and then applies another gate with a simple if condition, I would have expected a c_if instruction to be used instead. It is also unclear why the operations to create the entangled pair and the creation of the arbitary state to teleport are both applied to qubit 0.

What should happen?

I would have expected the entangled pair and the arbitary state to be created on different qubits and the use of c_if instead of the simple if condition.

Any suggestions?

I would have followed this guide and created something like:

from qiskit import *

qc = QuantumCircuit(3)
c0 = ClassicalRegister(1)
c1 = ClassicalRegister(1)
c2 = ClassicalRegister(1)
qc.add_register(c0)
qc.add_register(c1)
qc.add_register(c2)

qc.barrier()
# arbitrary state creation
qc.u(0.3,0.2,0.1,0)
# entangled pair creation
qc.h(1)
qc.cx(1,2)
qc.barrier()

qc.cx(0,1)
qc.barrier()
qc.h(0)
qc.barrier()
qc.measure([0,1],[0,1])
qc.barrier()
qc.x(2).c_if(c1, 1)
qc.z(2).c_if(c0, 1)
qc.draw()

Output:

        ░            ░       ░ ┌───┐ ░ ┌─┐    ░
  q_0: ─░────────────░───■───░─┤ H ├─░─┤M├────░───────────────
        ░ ┌───┐      ░ ┌─┴─┐ ░ └───┘ ░ └╥┘┌─┐ ░
  q_1: ─░─┤ H ├──■───░─┤ X ├─░───────░──╫─┤M├─░───────────────
        ░ └───┘┌─┴─┐ ░ └───┘ ░       ░  ║ └╥┘ ░  ┌───┐  ┌───┐
  q_2: ─░──────┤ X ├─░───────░───────░──╫──╫──░──┤ X ├──┤ Z ├─
        ░      └───┘ ░       ░       ░  ║  ║  ░  └─╥─┘  └─╥─┘
                                        ║  ║       ║   ┌──╨──┐
c15: 1/═════════════════════════════════╩══╬═══════╬═══╡ 0x1 ╞
                                        0  ║    ┌──╨──┐└─────┘
c16: 1/════════════════════════════════════╩════╡ 0x1 ╞═══════
                                           0    └─────┘
c17: 1/═══════════════════════════════════════════════════════

Thanks in advance, I wish you a happy and productive day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions