Tutorial 7 — Teleportation with a Relay Node
Objective: Teleport a quantum state across a multi-hop path using an intermediate relay node via the execute_teleportation() protocol.
Quantum teleportation uses entanglement as a resource to transfer an unknown quantum state from a source to a target. In qnet-core, you can specify explicit relay nodes to bridge distances where direct fidelity would be too low.
Define a 3-Node Chain
from qnet_core import QNetEngine, NodeDefinition, LinkDefinition, TeleportationParameters
engine = QNetEngine()
nodes = [
NodeDefinition(id="Alice", memory_lifetime_t2=1.0), # source (sender)
NodeDefinition(id="Charlie", memory_lifetime_t2=0.8), # relay node
NodeDefinition(id="Bob", memory_lifetime_t2=1.0), # target (receiver)
]
links = [
LinkDefinition("Alice", "Charlie", distance_km=25.0, base_fidelity=0.90,
generation_rate_hz=500.0),
LinkDefinition("Charlie", "Bob", distance_km=25.0, base_fidelity=0.90,
generation_rate_hz=500.0),
]
engine.define_network(nodes, links)
Configure and Execute Teleportation
teleport_params = TeleportationParameters(
source_node="Alice",
target_node="Bob",
state_fidelity=0.95, # desired output state fidelity
classical_bandwidth_ms=100.0, # time for classical channel communication
)
# Explicitly specify the relay node to bridge the two hops
teleport_params.relay_nodes = ["Charlie"]
outcome = engine.execute_teleportation(teleport_params)
print("=== Quantum State Teleportation ===")
print(f"Success: {outcome.success}")
print(f"Teleportation fidelity: {outcome.teleportation_fidelity:.4f}")
print(f"Resource entanglement fidelity: {outcome.resource_entanglement_fidelity:.4f}")
print(f"Latency: {outcome.latency_ms:.1f} ms")
print(f"Path: {' → '.join(outcome.path)}")
print(f"Classical bits sent: {outcome.classical_bits_transferred}")
Result Fields
| Field | Type | Description |
|---|---|---|
success | bool | Whether teleportation succeeded |
teleportation_fidelity | float | Fidelity of the teleported state (how close to input) |
resource_entanglement_fidelity | float | Fidelity of the resource entanglement links used |
latency_ms | float | End-to-end latency (entanglement + classical communication) |
path | List[str] | Node IDs traversed during the protocol |
classical_bits_transferred | int | Number of classical bits transmitted via the relay |
Compare: Direct vs Relayed
# Direct attempt (single long hop, lower fidelity)
direct_links = [
LinkDefinition("Alice", "Bob", distance_km=50.0, base_fidelity=0.75,
generation_rate_hz=300.0),
]
engine_direct = QNetEngine()
engine_direct.define_network(
[NodeDefinition(id="Alice", memory_lifetime_t2=1.0),
NodeDefinition(id="Bob", memory_lifetime_t2=1.0)],
direct_links,
)
direct_params = TeleportationParameters(
source_node="Alice", target_node="Bob",
state_fidelity=0.95, classical_bandwidth_ms=100.0,
)
# No relay nodes — single long hop
direct_outcome = engine_direct.execute_teleportation(direct_params)
print(f"Direct — success: {direct_outcome.success}, fidelity: {direct_outcome.teleportation_fidelity:.4f}")
print(f"Relayed — success: {outcome.success}, fidelity: {outcome.teleportation_fidelity:.4f}")
print("\n=> Relayed teleportation trades latency for higher output fidelity.")
Teleportation Protocol Flow
- Resource entanglement — establish entangled pairs across the path (including relay links)
- Bell-state measurement — source performs BSM on input state + local entangled pair
- Classical communication — send BSM results through the classical channel
- Unitary correction — target applies corrections based on received classical bits
TeleportationStats (Planned)
The TeleportationStats Monte Carlo ensemble type is planned but not yet implemented. Call execute_teleportation() repeatedly in your own loop for statistics.
What's next
- Distributed Computing — Star — multi-party quantum protocols
- Comparing Candidate Topologies — evaluate network designs