SimulaQron Programming Examples¶
SimulaQron offers three ways to write quantum network programs, from highest-level to lowest-level:
New SDK (
examples/new-sdk/) — The recommended approach for simple quantum apps using the NetQASM SDK. Programs useNetQASMConnectionandEPRSocketfor quantum operations, andSimulaQronClassicalClient/SimulaQronClassicalServerfor classical messaging. Start here if you are new to SimulaQron.Event-based (
examples/event-based/) — Builds on the new SDK by adding a state-machine pattern for classical messaging. Each node defines states, message handlers, and a dispatch table. This is the recommended pattern for protocols that interleave classical negotiation with quantum operations.Native mode (
examples/native-mode/) — The low-level Twisted interface that talks directly to SimulaQron’s virtual quantum nodes. This is Python-specific and more verbose, but gives full control over the simulation backend.
How to get the examples¶
The code of the examples can be found in SimulaQron GitHub repository.
Clone this repository using git:
git clone https://github.com/SoftwareQuTech/SimulaQron.git
All the examples can be found in the examples folder.
When running one of the examples mentioned below, we assume that you have already made your way through Getting Started and you have the virtual node servers up and running.
New SDK examples¶
Overview — Key concepts:
NetQASMConnection,EPRSocket,flush(), file structureTemplate — Getting started: single-node and client-server templates
CorrRNG — EPR pairs between two nodes, correlated measurement
Teleport — Quantum teleportation with classical correction messages
ExtendGHZ — Three-party entanglement, multiple EPR sockets
MidCircuitLogic — Multiple
flush()calls for mid-circuit classical decisions
Event-based examples¶
Overview — Event-based programming model and state machines
PingPong — Classical ping-pong between two nodes
PolitePingPong — State-machine message dispatch pattern
QuantumCorrRNG — Quantum correlated RNG with state machine
QuantumCorrRNGVerified — Correlated RNG with verification protocol
Native mode examples¶
Template — Template for programming in native (Twisted) mode
CorrRNG — Correlated randomness using native mode
Teleport — Teleportation using native mode
GraphState — Distributing a graph state across four nodes