Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MattePalte opened this issue Feb 28, 2024 · 1 comment
Open

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

MattePalte opened this issue Feb 28, 2024 · 1 comment

Comments

@MattePalte
Copy link

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.

@MattePalte
Copy link
Author

This would affect also the korean version:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant