Quantum Entanglement Link
quantumnet — a quantum communication network simulation stack
A quantum link fails quietly. Fidelity leaks away through noise, distance and the time spent waiting in memory, and a route that looks short can arrive too degraded to extract a key from. quantumnet simulates the whole path — density-matrix states, noise channels, swapping, memory decay — and reports the fidelity that survives it. This page is the reference: what each module does, what each command returns, and where the simulation stops.
§1The problem
A classical mesh asks which path a packet takes. A quantum one has to answer a harder question before anything moves: where do the repeaters go, and what fidelity is left when the entanglement arrives?
Entanglement cannot be copied, so it cannot be cached and re-sent. It is created between two nodes, consumed by a Bell-state measurement to extend the link further, and degraded the whole time it waits in memory. A repeater chain is therefore only as good as its worst link, and the arithmetic of the chain decides whether a route is usable at all.
Hardware cannot answer that question cheaply. A simulator can, and it can answer it for a thousand topologies before anyone books lab time.
§2What it models
States are density matrices, so decoherence is modelled directly rather than implied. Each channel acts on the state, and the metrics that matter for routing — fidelity and entropy — are read back from it rather than tracked separately.
| Channel | Effect | Where it applies |
|---|---|---|
| depolarising | Loss of polarisation toward the maximally mixed state | Generic link error |
| dephasing | Loss of phase coherence with no energy change | Memory T2 |
| amplitude damping | Relaxation toward the ground state | Memory T1, spontaneous emission |
| attenuation | Distance-dependent loss on a link | Topology edges |
| measurement | Projective or POVM, with state collapse | Bell-state measurement at a repeater |
Estimators
Noise is characterised on the captured window rather than assumed from a datasheet. The estimator ordering
H_90B ≥ H_hist ≥ H_Shannon is checked in the validation suite, which is what makes the
reported fidelity trustworthy at the pessimistic end.
§3Modules
| Module | Responsibility |
|---|---|
| core — primitives | |
| qubit | Density-matrix states, fidelity and entropy metrics |
| gate | Unitary gates, Pauli algebra, multi-qubit tensor products |
| measurement | Projective and POVM measurement with state collapse |
| noise | Depolarising, dephasing and amplitude-damping channels |
| channel | Quantum and classical links with distance-dependent attenuation |
| physical | Fibre and hardware impairments mapped to an attenuation budget |
| stabilizer | Clifford tableau simulation under Gottesman–Knill |
| scheduler | Asynchronous discrete-event core |
| ipc_node | One operating-system process per network node |
| protocols — ten implemented | |
| bb84 | QKD with basis reconciliation, QBER estimation and an intercept-resend eavesdropper |
| e91 | Ekert entanglement-based QKD, security from Bell inequality violation |
| bell | Bell-state preparation, Bell measurement, CHSH inequality tests |
| teleportation | Unknown state moved over a shared EPR pair plus two classical bits |
| superdense | Two classical bits carried by one qubit |
| swapping | Entanglement extended between nodes that never interacted |
| distillation | BBPSSW and Deutsch purification rounds |
| memory | Buffer dynamics with T1 relaxation and T2 dephasing |
| shor | Nine-qubit code: encoding, syndrome measurement, recovery |
| steane | Seven-qubit CSS code, correcting bit and phase flips |
| topology — placement and routing | |
| graph | Nodes, optical links and per-edge fidelity models |
| routing | Fidelity-constrained entanglement routing over Bell-state swaps |
| schedule | Time-aware entanglement distribution plan |
| visualize | Dependency-free ASCII rendering of a topology and a route |
| ghostnet | Import a live Global Ghost Net topology export and route over it |
§4Commands
Fifteen commands, dispatched by py -m quantumnet. The protocol demos write to stdout; the
bridge commands emit exactly one JSON document on stdout and keep everything else on stderr, so they
compose in a pipeline.
| Command | What it does |
|---|---|
| protocol demonstrations | |
| bb84 | Run a key exchange and report the QBER with and without an eavesdropper |
| e91 | Run the Ekert protocol and report the CHSH value |
| teleport | Teleport a state and report the reconstructed fidelity |
| superdense | Encode and decode two classical bits through one qubit |
| swap | Extend entanglement across an intermediate node |
| shor | Inject an error into the nine-qubit code and recover it |
| steane | The same for the seven-qubit CSS code |
| distill | Run purification rounds and report purity gained per pair spent |
| memory | Hold a state in the buffer and report fidelity against time |
| all | Every demonstration in sequence |
| simulation and routing | |
| stabilizer | Clifford tableau simulator for circuits too large to track as vectors |
| physical | Turn fibre and hardware metrics into an attenuation budget |
| topology | Build a graph, route entanglement across it, render ASCII; --max-hops is bounded to 1–8 |
| ghost-net | Route over a live mesh topology export and emit the route as one JSON document |
| qkd-derive | Derive key material at an explicit fidelity and seed, with no routing |
# route entanglement across a live mesh export py -m quantumnet ghost-net --topology mesh.json {"route": [0, 4, 9, 11], "fidelity": 0.941, "distilled": true, "hops": 3} # key material at an explicit fidelity py -m quantumnet qkd-derive --fidelity 0.94 --out key.bin # a topology, routed and rendered as ASCII py -m quantumnet topology --nodes 12 --route 0 11
§5Ghost-Net bridge
topology/ghostnet.py imports a topology export from Global Ghost Net and routes entanglement
across exactly the nodes it describes, so the same map that carries packets decides where quantum links
could exist.
A route's end-to-end fidelity is the scheduled value once every swap and every memory hold on the path is accounted for. If that value is too low for QKD to extract a key, the route is distilled — BBPSSW rounds over 256 pairs — until it clears the threshold. Then a real BB84 exchange runs at the route's own noise level and produces the key material.
- Input
- A topology export: node identifiers and the links between them
- Route cost
- Fidelity after swaps, memory decay and optional distillation
- Output
- One JSON document: route, end-to-end fidelity, whether distillation was needed, hop count
- Key material
- 32 bytes, derived at the route's fidelity from a stated seed
§6Scope and limits
- Real
- The quantum mechanics: states, gates, measurement collapse, noise channels, the stabilizer formalism, the error-correcting codes, distillation, and the fidelity arithmetic.
- Modelled
- The hardware and the network. There are no photons, no fibre and no sockets.
ipc_nodeuses real processes; the links between them are modelled. - Not claimed
- These are simulator results and do not predict what physical hardware would achieve.
§7Tests
git clone https://github.com/KELLERBABG/QEL cd QEL py -m pip install -e ".[dev]" py -m pytest -q # about 80 seconds py -m quantumnet all # every protocol demo
The suite covers each module directly: gates and measurement, the noise channels, the estimator ordering, each protocol against its closed-form expectation, routing and scheduling, and the JSON bridge contract. Run it before trusting a number on this page.