Teleportation¶
A two-program example: Alice (the sender) and Bob (the receiver). Together they implement quantum teleportation of a single qubit.
Simulating the online part
The "online" portion of the flow shown above — the actual execution of the compiled .iqoala programs against a Qoala runtime, including entanglement generation and inter-node messaging — can be simulated end-to-end with qoala-sim.
The two programs run on different nodes and only communicate through two channels. The first is an EPR pair generated by Entangle("…") on each side — the runtime arranges the underlying entanglement protocol; from the program's perspective, calling Entangle("Bob") on Alice's side and Entangle("Alice") on Bob's side gives each of them the local half of a shared Bell pair. The second is a classical channel carrying the two correction bits from Alice to Bob, established the moment one program calls send_int and the other calls the matching recv_int against the same remote name.
Files¶
The two programs live in qoala-compiler/examples/teleportation/, and the documentation mirrors them page-for-page:
| File | Role |
|---|---|
examples/teleportation/alice.py |
Sender. Holds the qubit to teleport, performs the Bell-state measurement, sends the correction bits. |
examples/teleportation/bob.py |
Receiver. Receives the corrections, applies them conditionally, measures the recovered qubit. |
The Sender walkthrough is the fully documented version of alice.py. The Receiver walkthrough is the fully documented version of bob.py, and it doubles as the worked example for the SDK's branching machinery (if_cond, ScopedQubit, and the with t: / with f: arms).
Why two programs?¶
The Qoala execution model assumes each network node runs its own program independently. The two programs declare each other as their Remote(...) and exchange information only through entanglement and classical send/recv. There is no shared address space; every value the receiver acts on either came from a measurement it performed locally or from a recv_int it executed.
Run them¶
python examples/teleportation/alice.py
prints Alice's HIR module on stdout, and the same for bob.py. Each module is emitted with singular_comm_ops=True, so the classical send/recv ops are already in single-value form. To take either through the rest of the pipeline, see Continuing the pipeline.