Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › programming

How to Build a Simple Quantum Teleportation Circuit in a Quantum Simulator

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A three-qubit circuit can transfer an unknown quantum state from Alice’s qubit to Bob’s qubit in a simulator. The recipe is: prepare a Bell pair, entangle the input with Alice’s half, measure Alice’s two qubits, send those two classical bits, and conditionally apply Pauli corrections to Bob’s qubit. To test the result with a known input, undo the input preparation on Bob’s qubit and measure; an ideal simulator returns 0 on that verification bit.

This is state transfer, not movement of matter. The protocol consumes shared entanglement, requires ordinary classical communication, does not clone the input, and cannot send information faster than light.

As an Amazon Associate I earn from qualifying purchases.

What quantum teleportation actually transfers

Quantum teleportation moves the state carried by one qubit onto a distant qubit without measuring the unknown state directly. The original state is destroyed by Alice’s measurement, so there are not two copies at the end. Bob receives the state only after he gets Alice’s two classical measurement results and performs the matching correction.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The standard demonstration needs three qubits:

Qubit Role What happens to it
0 Input (Alice’s secret state) Prepared in the state to be teleported, then measured by Alice
1 Alice’s half of an entangled pair Entangled with qubit 2, then measured with qubit 0
2 Bob’s half of the entangled pair Receives a conditional X and/or Z correction

Qubits 1 and 2 form one shared e-bit. Creating that pair is the resource that makes teleportation possible; it is consumed during the Bell measurement. Alice’s two classical bits are not optional metadata: without them Bob cannot know which correction is required.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

What you need for a local simulator

  • Python 3 and a virtual environment are recommended.
  • Qiskit for circuit construction.
  • A simulator backend such as Qiskit Aer. A local simulator is sufficient; no quantum-computing account or physical processor is required for this walkthrough.
  • A known test state. Using a known preparation lets you verify the transfer deterministically instead of trying to compare an unknown state directly.

Install the packages in the environment you intend to use:

python -m pip install qiskit qiskit-aer

Qiskit syntax for conditional operations has changed across releases. The circuit logic below is stable, but use the conditional form supported by your installed version; newer releases provide an if_test context, while older releases commonly use c_if.

The circuit in conceptual order

1. Prepare the input

Choose a state that is easy to prepare and easy to undo. For example, applying Ry(theta) to qubit 0 creates a test state that depends on the angle theta. The protocol itself does not require the state to be known; the known preparation is only for verification.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Create the Bell pair

Apply a Hadamard gate to qubit 1, then a controlled-NOT from qubit 1 to qubit 2. In symbols, this creates the entangled state usually written as (|00> + |11>) / sqrt(2) for those two qubits.

qc.h(1)
qc.cx(1, 2)

3. Perform Alice’s Bell-measurement transformation

Entangle the input with Alice’s Bell-pair half using a CNOT from qubit 0 to qubit 1, then apply a Hadamard to qubit 0:

qc.cx(0, 1)
qc.h(0)

After these gates, measuring qubits 0 and 1 in the computational basis produces two classical bits. The measurement outcomes select which Pauli operation Bob must apply.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

4. Measure Alice’s qubits

For the register convention used here, qubit 0 is measured into classical bit 0 and qubit 1 into classical bit 1:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
qc.measure(0, 0)
qc.measure(1, 1)

5. Apply Bob’s correction

With that exact wiring, apply Z to Bob’s qubit when classical bit 0 is 1, and apply X when classical bit 1 is 1. Both conditions can be true, in which case Bob applies both corrections.

Measured bit 0 (from q0) Measured bit 1 (from q1) Operation on q2
0 0 Identity
0 1 X
1 0 Z
1 1 X and Z (order changes only a global phase)

The labels “bit 0” and “bit 1” describe this circuit’s classical destinations, not an immutable rule about every program. Other examples place the input in a different qubit, reverse control and target wires, or map measurement results into a register whose displayed order is reversed. Always derive the correction from your own measurement mapping.

A complete Qiskit example with inverse-preparation verification

The following example uses Ry(theta) as the known input preparation. It measures Alice’s qubits, performs real-time feed-forward in the simulator, undoes the same rotation on Bob’s qubit, and measures a verification bit. In an ideal run, that final bit is always 0.

from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator

# Any angle is suitable for this known test state.
theta = 0.73
qc = QuantumCircuit(3, 3)

# 1. Prepare |psi> = Ry(theta)|0> on the input qubit.
qc.ry(theta, 0)

# 2. Make the Bell pair shared by Alice (q1) and Bob (q2).
qc.h(1)
qc.cx(1, 2)

# 3. Alice's Bell-measurement transformation.
qc.cx(0, 1)
qc.h(0)

# 4. Alice measures q0 -> c0 and q1 -> c1.
qc.measure(0, 0)
qc.measure(1, 1)

# 5. Conditional corrections for this exact mapping.
# Newer Qiskit releases:
with qc.if_test((qc.clbits[0], 1)):
    qc.z(2)
with qc.if_test((qc.clbits[1], 1)):
    qc.x(2)

# 6. Verification only: undo the known preparation on Bob.
qc.ry(-theta, 2)
qc.measure(2, 2)

simulator = AerSimulator()
result = simulator.run(qc, shots=1024).result()
print(result.get_counts())

If your installed Qiskit version does not support if_test, express the same two conditions with that release’s classical-control API, commonly qc.z(2).c_if(qc.clbits[0], 1) and qc.x(2).c_if(qc.clbits[1], 1). The important part is not the spelling of the method; it is that the condition tests the classical bit that received each measurement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because Qiskit displays the highest-index classical bit on the left of a count string, the verification bit c2 appears as the leftmost character in the three-bit keys. Ideal results therefore have a leading 0, such as 000, 001, 010, or 011. The lower two characters vary with Alice’s random Bell-measurement outcomes. A key beginning with 1 indicates that the verification measurement failed for that shot.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Why the inverse gate proves the transfer

After the corrections, Bob should hold exactly the state that was prepared on qubit 0. Directly comparing two arbitrary quantum states is not possible with one measurement, so the test uses a reversible “uncompute” operation.

  1. Prepare the known state with a gate sequence U on qubit 0.
  2. Run teleportation and corrections.
  3. Apply U-dagger, the inverse of that preparation, to Bob’s qubit.
  4. Measure Bob. A correctly transferred state becomes |0>, so the verification bit should be 0.

For the example, U is Ry(theta) and U-dagger is Ry(-theta). The inverse rotation is not part of teleportation. It is a diagnostic added after the protocol; omitting it is correct when you want Bob’s state itself rather than a pass/fail test.

Statevector simulation versus shot simulation

Statevector view

A statevector simulator represents the complete ideal amplitudes. It is useful for inspecting how the three-qubit state evolves before measurement and for checking that Bob’s reduced state matches the prepared input after the correction. Statevectors expose amplitudes and relative phase directly, but measurements and classical feed-forward require care: measuring Alice’s qubits collapses the state, so inspect the appropriate point in the circuit or use a simulator feature that saves the statevector before the final measurements.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Shot-based view

A shot-based run executes the circuit repeatedly and returns a histogram of classical bit strings. This is closer to how an experiment reports data and works naturally with mid-circuit measurements and conditional operations. For the inverse-preparation test, every ideal shot has verification bit 0, although the two Bell-measurement bits are randomly distributed.

Do not interpret the random distribution of Alice’s two bits as a failure. Those bits carry the correction information. The pass/fail signal is the verification bit measured after Bob’s correction and inverse preparation.

Understanding the correction rule mathematically

Let the input be |psi>, and let Alice’s two measurement results be m0 and m1 under the wiring used above. Before correction, Bob’s qubit is one of four related states. The correction is represented compactly as X^m1 Z^m0 (up to an irrelevant global phase). Thus:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
  • m0 = 0, m1 = 0: no correction.
  • m0 = 0, m1 = 1: apply X.
  • m0 = 1, m1 = 0: apply Z.
  • m0 = 1, m1 = 1: apply both X and Z.

This relation explains why a swapped classical-register convention can make apparently reversed code still look plausible while producing the wrong state. The correction exponents must follow the actual destinations of the measured bits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common register-order mistakes

Reading a count string backwards

Many Qiskit count displays write the highest classical-bit index first. If you measure q0 to c0 and q1 to c1, a displayed string such as 010 should be read as c2=0, c1=1, c0=0. It is not evidence that the measurements occurred in the order shown on screen.

Copying a conditional line from another circuit

An instructional example may assign the input to q2, use a different classical register, or measure into reversed destinations. Copying its X/Z conditions without copying its wiring changes the protocol. Write a small mapping table beside your circuit before adding conditions.

Applying corrections before measurement

Bob’s correction depends on classical data that does not exist until Alice measures. Applying a fixed X or Z before the measurement is a different circuit and will only work for selected inputs by coincidence.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting a failed verification

Symptom Likely cause Fix
Verification bit is sometimes 1 in an ideal simulator A correction condition is attached to the wrong classical bit, or an X/Z assignment is swapped. Confirm q0->c0 and q1->c1 (or your chosen mapping), then rebuild the four-row correction table.
All counts look different from the example Classical bit strings are displayed in reverse index order, or the input angle is different. Decode the string by classical-bit index and check the leading verification bit separately.
The circuit raises an error at if_test Your Qiskit version uses an older control-flow API. Use the version-appropriate c_if form, keeping the same bit-to-condition mapping.
Bob’s qubit is measured before the correction The final measurement was placed too early, or the simulator was given a circuit without dynamic feed-forward. Keep Alice’s measurements, conditional operations, inverse preparation, and Bob’s verification measurement in that order.
A statevector comparison appears to differ by a sign Two states may differ only by a global phase, which has no measurement consequence. Use probabilities, a density-matrix comparison, or inverse-preparation measurement rather than raw amplitude equality alone.
Verification fails only after adding noise Noise, readout errors, and imperfect gates alter real or noisy-simulator outcomes. Separate protocol logic from hardware performance; first confirm an ideal run, then characterize noise with repeated shots.

What the simulator demonstrates—and what it does not

An ideal simulator executes the mathematical circuit exactly, so a perfect verification result confirms that the gate sequence and classical mapping implement teleportation for the chosen input. It does not demonstrate that a physical processor will produce the same histogram. Real devices add gate error, decoherence, readout error, and timing constraints.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Hardware execution also needs support for mid-circuit measurement and real-time conditional operations. A device may require a dynamic-circuit mode, impose restrictions on which qubits can be measured and fed forward, or report a lower verification rate than the ideal circuit. Any hardware percentage belongs to that particular device, calibration, circuit layout, and run; it is not a general teleportation success rate.

Why teleportation does not violate physics

No faster-than-light message

Bob’s qubit has a state correlated with Alice’s measurement, but Bob cannot select Alice’s random result or decode the input before receiving the two classical bits. The classical channel is limited by ordinary communication speed, so teleportation cannot be used for instantaneous messaging.

No cloning

A measurement on Alice’s two qubits consumes the original input relationship. The protocol transfers the state rather than leaving an intact copy on Alice’s side. This is consistent with the no-cloning principle.

Entanglement is a resource, not a signal

The pre-shared Bell pair establishes correlations, but entanglement alone does not carry a controllable message. The classical correction completes the transfer and consumes the shared pair in the process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Extending the experiment safely

Try other single-qubit preparations

Replace Ry(theta) with a sequence such as Rz(phi) followed by Ry(theta), then apply the exact inverse sequence in reverse order on Bob. For gates A followed by B, the inverse is B-dagger followed by A-dagger. Testing several angles and phases helps reveal a correction that happens to work for one real-valued state but fails for states with complex phase.

Inspect each correction branch

For debugging, run circuits that force or post-select each pair of Alice outcomes and verify that the corresponding Bob correction restores the input. This isolates the four branches of the protocol instead of hiding a single bad branch inside an aggregate histogram.

Separate protocol and verification circuits

Keep a copy that ends immediately after Bob’s correction when you want to study the teleported state, and a second copy that adds inverse preparation for a binary test. Mixing the diagnostic gate into a circuit intended to represent the protocol can make the final state difficult to interpret.

Minimal checklist before you run

  • There are exactly three logical qubits: input, Alice, and Bob.
  • The Bell pair uses H on Alice’s pair qubit followed by CX to Bob.
  • The Bell-measurement transformation is CX(input, Alice) followed by H(input).
  • Both Alice qubits are measured before Bob’s conditional operations.
  • Your correction table matches the actual classical-bit destinations.
  • The inverse of the known input preparation is applied only for verification.
  • The verification measurement is placed after correction and should be 0 for an ideal simulator.
  • Any nonzero verification result is investigated as a mapping, ordering, API, or noise issue before drawing conclusions.

Once this three-qubit circuit works, you have the core pattern used in larger protocols: prepare entanglement, perform a joint measurement, communicate classical outcomes, and apply feed-forward corrections. The simulator makes every step inspectable while preserving the essential distinction between quantum state transfer and classical communication.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

programmingQiskitQuantum Computingquantum simulatorquantum teleportation

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.