Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/itsubaki/qasm-playground/llms.txt

Use this file to discover all available pages before exploring further.

Quantum teleportation is a protocol that transfers the exact quantum state of one qubit to another qubit using a shared entangled pair and two classical bits of communication. The original qubit’s state is destroyed in the process (no-cloning theorem), but faithfully reconstructed on the target. This circuit teleports the state 0.92|0⟩ + 0.27(1+i)|1⟩ from qubit psi to qubit t — without ever moving psi itself.

Code

// Quantum Teleportation
//
// Transfers the state of psi to t using entanglement and classical communication.
// The final state of t is the same as the initial state of psi: 0.92|0> + 0.27(1+i))|1>.

OPENQASM 3.0;

gate h q { U(pi/2.0, 0, pi) q; }
gate cx c, t { ctrl @ U(pi, 0, pi) c, t; }
gate cz c, t { ctrl @ U(0, pi, 0) c, t; }

qubit psi;
qubit a;
qubit t;

reset psi;
reset a;
reset t;

// psi = 0.92|0> + 0.27(1+i))|1>
U(pi/4, pi/4, pi/4) psi;

h a;
cx a, t;
cx psi, a;
h psi;

cx a, t;
cz psi, t;

// t = 0.92|0> + 0.27(1+i))|1>
measure psi;
measure a;

Step-by-step explanation

Gate definitions Three gates are defined using the universal U gate:
  • h (Hadamard): U(pi/2, 0, pi) — creates superposition.
  • cx (CNOT): controlled U(pi, 0, pi) — entangles qubits and applies corrections.
  • cz (controlled-Z): controlled U(0, pi, 0) — applies a phase correction.
Preparing the state to teleport U(pi/4, pi/4, pi/4) psi initializes psi to the state 0.92|0⟩ + 0.27(1+i)|1⟩. This is an arbitrary state chosen to demonstrate that the protocol works for any input, not just a computational basis state. Creating the entangled channel
h a         →  a enters superposition: (|0⟩ + |1⟩)/√2
cx a, t     →  a and t become the Φ⁺ Bell pair: (|00⟩ + |11⟩)/√2
Qubit a (Alice’s half) and qubit t (Bob’s half) now share a maximally entangled state. t is physically located at the destination. Bell measurement on psi and a (Alice’s side)
cx psi, a   →  entangles psi with a
h psi       →  rotates psi into the Bell basis
After these two gates, the joint system of psi+a is in one of the four Bell states. The measurement outcomes of psi and a (two classical bits) encode which correction Bob needs to apply. Corrections on t (Bob’s side)
cx a, t     →  X correction: flips t if a measured as |1⟩
cz psi, t   →  Z correction: applies phase to t if psi measured as |1⟩
These two gates are controlled on the classical measurement outcomes through the quantum wires. After both corrections, t holds the original state of psi. Measuring psi and a measure psi and measure a collapse Alice’s qubits, providing the two classical bits that drive the corrections. The state of psi is irretrievably altered after measurement — consistent with the no-cloning theorem.

Expected output

After the protocol completes, qubit t is in the state:
0.92|0⟩ + 0.27(1+i)|1⟩
This matches the original state of psi exactly, including both the amplitude magnitudes and the complex phase. The measurement results of psi and a will each be 0 or 1 with equal probability across the four combinations (00, 01, 10, 11), but regardless of which pair is measured, the corrections always leave t in the correct state.
The two classical bits sent from Alice to Bob are essential. Without them, Bob cannot determine which correction to apply, and from his perspective, t looks maximally mixed. Classical communication is what makes the protocol work — teleportation does not transmit information faster than light.

Quantum mechanics concepts

No-cloning theorem — Quantum mechanics forbids copying an unknown quantum state. Teleportation circumvents this by destroying the original state during the Bell measurement, transferring the quantum information rather than duplicating it. Bell measurement — Measuring two qubits in the Bell basis (rather than the computational basis) is achieved by applying a CNOT followed by a Hadamard before measurement. The outcome projects the system onto one of the four Bell states and yields two classical bits. Entanglement as a resource — The shared Bell pair between a and t is the quantum channel. Teleportation consumes one ebit (unit of entanglement) per qubit teleported. Without pre-shared entanglement, the protocol cannot work. Classical communication — Two classical bits carry the information about which of the four possible correction operations Bob must apply. This is why teleportation requires a classical channel in addition to the entangled pair — one for quantum correlation, one for the correction instructions.

Build docs developers (and LLMs) love