MHP Build · Software release 0.1.1 (research preview), 16 November 2026 · MIT licence · Code: mhpbuild/Quantum-Chat
Abstract
We present Quantum Chat, an open-source simulator that carries UTF-8 text messages between two terminal users by superdense coding. Each two-bit symbol is encoded on one qubit of a fresh Bell pair and decoded jointly after that qubit is transferred. Messages are wrapped in a bounded frame with a SHA-256 checksum, and delivery is confirmed by a classical ACK with retry. A depolarising channel on the transferred qubit and bit errors on the ACK give a noise model with a closed-form confirmation probability. In 100 synthetic messages per condition, all 100 were received and confirmed without noise. With per-qubit depolarisation p = 0.002 and ACK bit error q = 0.0002, 94 were received exactly and 93 confirmed within five attempts. All numbers come from executed notebooks in the repository. The simulator is educational: it models an established protocol and makes no claim of physical quantum communication.
1. Introduction
Superdense coding, introduced by Bennett and Wiesner [1], sends two classical bits by transmitting one qubit, provided the sender and receiver already share an entangled pair. It is one of the simplest protocols in which entanglement is a resource that can be counted and spent.
Most demonstrations stop at four symbols on a circuit diagram. Quantum Chat follows the protocol all the way to a usable application: arbitrary text, two directions, corrupted frames, lost acknowledgements and retries. Every resource is accounted for, including the overhead that a fair comparison needs. The quantum part runs on Cirq and qsimcirq [4]; the terminals talk to the simulator over classical localhost TCP.
2. Protocol
The basis order is A, B: |00⟩, |01⟩, |10⟩, |11⟩. The sender holds qubit A and the receiver holds B after an initial distribution. The shared Bell pair is
To send bits , the sender applies and then to A, so the total operator is . After A arrives, the receiver applies CNOT and then H on A, and measures both qubits:
The global phase is unobservable, so the measurement returns on A and on B. The circuit at the top of this page shows the three stages.
No signalling. For every encoded state the receiver’s qubit alone is maximally mixed,
so whatever the sender chose [3]. More samples of B, or a classifier trained on them, cannot recover the message. Qubit A must arrive.
3. Implementation
The simulator separates the logical path into modules with explicit data boundaries. The receiving endpoint sees only bytes built from measurement outcomes, never the sender’s text, encoding choices or the global state.
| Module | Responsibility |
|---|---|
densechat/quantum.py |
Bell preparation, Z/X encoding, A-ownership transfer, one-shot measurements |
densechat/protocol.py |
Bounded UTF-8 frame, sequence and length, SHA-256, ACK binding |
densechat/session.py |
Endpoints, deduplication, retry and resource ledger |
densechat/server.py |
Classical loopback control server with real TCP byte counters |
densechat/cli.py |
Demo mode and terminal participants |
viewer.py |
Independent observer replay with privileged access to the global state |

Frame. A frame is a 15-byte header (magic, version, 64-bit sequence, 32-bit length), the UTF-8 payload of at most 4096 bytes, and a 32-byte SHA-256 digest. An ACK is 75 bytes, or 600 bits. The checksum detects accidental corruption; it is not authentication or encryption.
Cost. Each byte is four two-bit symbols, and each symbol consumes a fresh Bell pair. For a frame of L bytes sent R times, the model spends
A 25-byte message becomes a 72-byte frame, so one ideal attempt uses 288 Bell pairs. Real TCP control traffic is counted separately and is not part of the quantum ledger.
Receipt is not confirmation. A frame can be accepted while its ACK is lost (received = True, confirmed = False). Only a matching ACK stops retries, and a retry with the same sequence and fingerprint never adds a duplicate message.
4. Noise model
Transit of qubit A passes through a depolarising channel
so the joint decoder returns the correct symbol with probability and each wrong symbol with . With independent errors, an unchanged L-byte frame and an intact ACK (bit error ) succeed together with probability , and confirmation within R attempts follows:
For example, at p = 0.002 and q = 0.0002 a 72-byte frame has s ≈ 0.50 per attempt and ≈ 0.97 within five attempts. Bell preparation, storage, B distribution and local gates are otherwise ideal.
5. Results
All results below were computed by the notebooks with seed 20261106 on Python 3.12.16, cirq-core 1.7.0 and qsimcirq 0.22.1.
Symbol check. Each of the four inputs was sent 32 times, one fresh pair per shot. All 128 shots decoded correctly, and P(B = 0) = P(B = 1) = 0.5 for every encoded state.
Transport experiment. 100 unique synthetic messages per condition, in both directions. Ideal: no noise, one attempt. Noisy: p = 0.002, q = 0.0002, at most five attempts.
| Condition | Trials | Received exactly | Confirmed | 95% Wilson interval (confirmed) | Mean attempts |
|---|---|---|---|---|---|
| Ideal | 100 | 100 | 100 | 0.963 – 1.000 | 1.00 |
| Noisy | 100 | 94 | 93 | 0.863 – 0.966 | 2.42 |

Ensemble versus shots. For input 11 at p = 0.2, the exact density-matrix ensemble predicts 0.800 for the correct symbol and 0.0667 for each other. Across 512 independent one-shot runs, qsim returned 11 401 times (0.783), 10 47 times, 01 41 times and 00 23 times.

The Wilson intervals describe this simulation sample only. They are not a statement about hardware reliability.
6. Limitations
- Localhost TCP is a classical interface to a trusted simulator, not a physical quantum link.
- Noise is modelled only on A transit and on the ACK. There is no erasure, storage noise, imperfect Bell distribution, latency or adversary.
- The observer viewer reads the global state for diagnosis; no physical participant could.
- SHA-256 without a key detects accidental corruption, not a malicious peer.
- Messages are synthetic transport fixtures. Nothing here trains or evaluates a language model.
- No faster-than-light communication, entanglement-only signalling or quantum encryption is claimed.
7. Reproducibility and code
The code, notebooks and figures are in mhpbuild/Quantum-Chat. The three executed notebooks are readable here on the site:
- 01 · Superdense coding: Bell preparation, encoding, circuit, four-symbol verification and reduced states.
- 02 · Chat protocol: architecture, framing, cost accounting and the transport experiment.
- 03 · Observer and noise: coherence, density matrices, purity and noisy ensembles.
To reproduce, with Python 3.12:
git clone https://github.com/mhpbuild/Quantum-Chat.git && cd Quantum-Chat
python3.12 -m venv .venv && source .venv/bin/activate
python -m pip install --only-binary=:all: -r requirements.txt && python -m pip install --no-deps .
python -m unittest discover -s tests -v
python verify_chat.py
python scripts/execute_notebooks.py --output work/executed-notebooks
No API key, dataset download or model training is needed. Different backend versions or platforms can give different random sequences for the same seed.
References
- C. H. Bennett and S. J. Wiesner, “Communication via one- and two-particle operators on Einstein–Podolsky–Rosen states,” Physical Review Letters 69, 2881–2884 (1992). doi:10.1103/PhysRevLett.69.2881
- IBM Quantum Learning, “Superdense coding,” quantum.cloud.ibm.com (accessed 6 November 2026).
- IBM Quantum Learning, “Multiple systems and reduced states,” quantum.cloud.ibm.com (accessed 6 November 2026).
- Google Quantum AI, “Get started with qsimcirq,” quantumai.google; “Cirq DepolarizingChannel,” quantumai.google (accessed 6 November 2026).