Skip to content

Commit e5ee468

Browse files
Stephanie Wehnerclaude
andcommitted
docs: rewrite ConfNodes for single vs multi-machine, fix Examples links, add architecture figure
- ConfNodes.rst: clearly separate single-machine (CLI or run.sh) vs multi-machine (distributed) setup - Examples.rst: replace toctrees with descriptive links to each example page - Add netqasm_architecture.png (fixes broken image in Overview.rst) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent efb6477 commit e5ee468

File tree

3 files changed

+185
-125
lines changed

3 files changed

+185
-125
lines changed

docs/ConfNodes.rst

Lines changed: 154 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -7,139 +7,178 @@ SimulaQron uses two configuration files:
77
* ``simulaqron_settings.json`` — configures the simulation backend, timeouts, and other settings
88
(see :ref:`settings` in :doc:`GettingStarted`)
99

10-
-------------------------------
11-
Starting the SimulaQron backend
12-
-------------------------------
10+
-------------------------------------------
11+
Running all nodes on a single machine
12+
-------------------------------------------
1313

14-
The backend of a SimulaQron network is a set of running virtual nodes and their corresponding `VirtualNode` servers.
15-
Starting a SimulaQron network requires using SimulaQron and network configuration files.
14+
When developing and testing, you typically run all simulated nodes on one computer.
15+
In this case, all sockets use ``localhost`` and you just need distinct port numbers for each node.
1616

17-
To start the backend of a SimulaQron network run the command ``simulaqron start``.
17+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
Using the SimulaQron CLI
19+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1820

19-
The command can receive certain arguments to control the simulated network:
21+
The ``simulaqron`` command manages the backend for you. To start a network with nodes Alice and Bob::
2022

21-
* ``--simulaqron-config-file=PATH`` (optional): Specifies a path for the SimulaQron config file to use for the backend.
22-
If not given, simulaqron will try to read a file named ``simulaqron_settings.json`` in the current folder.
23-
* ``--network-config-file=PATH`` (optional): Specifies a path for the network config file to use for the backend. If
24-
not given, simulaqron will try to read a file named ``simulaqron_network.json`` in the current folder.
25-
* ``--name=<network-name>`` (optional): Specifies the name of the network to start. This name must correspond to one
26-
of the names specified on the given network configuration file. If this argument is not given, this value is
27-
defaulted to ``default``.
28-
* ``--nodes <nodes_list>`` (`required`): Specifies which nodes to simulate. The ``<nodes_list>`` value is a comma
29-
separated list of the nodes names to start. All the specified node names must exist within the specified network
30-
inside the network configuration file.
23+
simulaqron start --nodes Alice,Bob
3124

32-
How to adjust the nodes and the topology of the network is described below.
25+
This reads ``simulaqron_network.json`` and ``simulaqron_settings.json`` from the current directory (or uses
26+
defaults), starts the virtual node servers, the QNodeOS servers, and the classical communication servers for
27+
each node listed.
3328

34-
.. warning:: ``simulaqron start`` can fail if any of the ports specified in the config files are already in use by a
35-
running SimulaQron network or another program.
29+
To stop the backend::
3630

37-
If you want to start a network with, for example, the three nodes Alex, Bart, Curt from the network named ``network``,
38-
simply type::
31+
simulaqron stop
3932

40-
simulaqron start --name network --nodes Alex,Bart,Curt
33+
If something went wrong (e.g. the process was killed) and SimulaQron thinks the network is still running::
34+
35+
simulaqron reset
36+
37+
The ``simulaqron start`` command accepts these arguments:
38+
39+
* ``--nodes <nodes_list>`` (**required**): Comma-separated list of node names to start. These must exist in
40+
the network configuration file.
41+
* ``--simulaqron-config-file=PATH`` (optional): Path to a SimulaQron settings file. Defaults to
42+
``simulaqron_settings.json`` in the current folder.
43+
* ``--network-config-file=PATH`` (optional): Path to a network configuration file. Defaults to
44+
``simulaqron_network.json`` in the current folder.
45+
* ``--name=<network-name>`` (optional): Name of the network to start (must match a name in the config file).
46+
Defaults to ``default``.
47+
48+
.. warning:: ``simulaqron start`` will fail if any of the ports specified in the config files are already in
49+
use by a running SimulaQron network or another program.
50+
51+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52+
Using per-example run scripts
53+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54+
55+
Each example in ``examples/new-sdk/`` and ``examples/nativeMode/`` includes a ``run.sh`` script that starts
56+
the SimulaQron backend and launches the node programs. This is the easiest way to try an example::
57+
58+
cd examples/new-sdk/corrRNG
59+
sh run.sh
60+
61+
The ``run.sh`` script reads the ``simulaqron_network.json`` and ``simulaqron_settings.json`` in the example
62+
directory, so each example is self-contained.
63+
64+
-------------------------------------------
65+
Running nodes on separate machines
66+
-------------------------------------------
67+
68+
To simulate a real distributed quantum network, you can run each node on a different physical computer.
69+
In this case, you need to:
70+
71+
1. **Use real hostnames/IPs** instead of ``localhost`` in the ``simulaqron_network.json`` file.
72+
Each node's sockets must be reachable from the other machines.
73+
74+
2. **Copy the same** ``simulaqron_network.json`` **to every machine**. All nodes must agree on the
75+
network configuration.
76+
77+
3. **Start only the local node** on each machine. On the machine running Alice::
78+
79+
simulaqron start --nodes Alice
80+
81+
On the machine running Bob::
82+
83+
simulaqron start --nodes Bob
84+
85+
4. **Run your node program** on each machine after the backend is started.
86+
87+
An example ``simulaqron_network.json`` for a distributed setup::
88+
89+
{
90+
"default": {
91+
"nodes": {
92+
"Alice": {
93+
"app_socket": ["192.168.1.10", 8000],
94+
"qnodeos_socket": ["192.168.1.10", 8001],
95+
"vnode_socket": ["192.168.1.10", 8004]
96+
},
97+
"Bob": {
98+
"app_socket": ["192.168.1.20", 8000],
99+
"qnodeos_socket": ["192.168.1.20", 8001],
100+
"vnode_socket": ["192.168.1.20", 8004]
101+
}
102+
},
103+
"topology": null
104+
}
105+
}
106+
107+
.. note:: When running on separate machines, the port numbers can be the same on each machine since they
108+
bind to different IP addresses.
41109

42110
.. _networkConfig:
43111

44112
-----------------------
45113
Configuring the network
46114
-----------------------
47-
SimulaQron requires specifying a json-based network configuration. This configuration states the name of the node,
48-
and IP address/port tuples to correctly connect the SimulaQron simulations and classical communication sockets.
49115

50-
For each configured node, you need to specify IP and address for 3 fields:
116+
The network configuration file (``simulaqron_network.json``) defines nodes and their socket assignments.
117+
For each node, you specify IP and port for three sockets:
51118

52-
* The ``app_socket`` field, which specifies the IP and port for connecting classical communication sockets.
53-
* The ``qnodeos_socket`` field, which specifies the IP and port for connecting the QnodeOS server, used to interpret
54-
NetQASM objects.
55-
* The ``vnode_socket`` field, which specifies the IP and port for the SimulaQron VirtualNode object, which runs the
56-
quantum simulation.
119+
* ``app_socket`` — classical communication between application-level nodes
120+
* ``qnodeos_socket`` — connection to the QNodeOS server that interprets NetQASM subroutines
121+
* ``vnode_socket`` — connection to the SimulaQron VirtualNode that runs the quantum simulation
57122

58-
Using the CLI you can add nodes to a network::
123+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124+
Using the CLI to add nodes
125+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126+
127+
You can build up a network incrementally using the CLI::
59128

60129
simulaqron nodes add Maria
61130

62-
which adds the node Maria to the default network "default". If you want add a node to another network you can do::
131+
This adds Maria to the default network with random ports on ``localhost``. To add to a different network::
63132

64133
simulaqron nodes add Maria --network-name="OtherNetwork"
65134

66-
which adds Maria to the network "OtherNetwork". With no extra arguments, this invocation will configure all the
67-
sockets fields on ``localhost``, assigning a random port in the 8000-9000 range.
68-
You can also specify hostname and port numbers to be used for this node including what it's neighbors are using the
69-
arguments:
135+
You can also specify explicit hostnames and ports:
136+
137+
* ``--hostname``
138+
* ``--app-port``
139+
* ``--qnodeos-port``
140+
* ``--vnode-port``
141+
* ``--neighbors``
70142

71-
* ``--hostname``
72-
* ``--app-port``
73-
* ``--qnodeos-port``
74-
* ``--vnode-port``
75-
* ``--neighbors``
143+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144+
Writing the JSON config manually
145+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76146

77-
If you want to build up a (or many) more complex network, it can become tedious to do this through the CLI.
78-
You can instead write your own network config file, as a .json file.
79-
An example of such a file can be seen below which contains two networks ("default" and "small_network") which the
80-
nodes "Alice", "Bob" and "Test" respectively::
147+
For more complex setups, write the ``simulaqron_network.json`` file directly.
148+
Here is an example with two networks ("default" and "small_network")::
81149

82150
{
83151
"default": {
84152
"nodes": {
85153
"Alice": {
86-
"app_socket": [
87-
"localhost",
88-
8000
89-
],
90-
"qnodeos_socket": [
91-
"localhost",
92-
8001
93-
],
94-
"vnode_socket": [
95-
"localhost",
96-
8004
97-
]
154+
"app_socket": ["localhost", 8000],
155+
"qnodeos_socket": ["localhost", 8001],
156+
"vnode_socket": ["localhost", 8004]
98157
},
99158
"Bob": {
100-
"app_socket": [
101-
"localhost",
102-
8007
103-
],
104-
"qnodeos_socket": [
105-
"localhost",
106-
8008
107-
],
108-
"vnode_socket": [
109-
"localhost",
110-
8010
111-
]
159+
"app_socket": ["localhost", 8007],
160+
"qnodeos_socket": ["localhost", 8008],
161+
"vnode_socket": ["localhost", 8010]
112162
}
113163
},
114164
"topology": null
115-
}
165+
},
116166
"small_network": {
117167
"nodes": {
118168
"Test": {
119-
"app_socket": [
120-
"localhost",
121-
8031
122-
],
123-
"qnodeos_socket": [
124-
"localhost",
125-
8043
126-
],
127-
"vnode_socket": [
128-
"localhost",
129-
8089
130-
]
169+
"app_socket": ["localhost", 8031],
170+
"qnodeos_socket": ["localhost", 8043],
171+
"vnode_socket": ["localhost", 8089]
131172
}
132173
},
133174
"topology": null
134175
}
135176
}
136177

137-
If you want simulaqron to use your custom network.json file simply place it in the same folder where you are running
138-
your code, and name it ``simulaqron_network.json``. You can also use name it differently, but make sure that you
139-
manually load this file in your python code::
178+
Place this file in the same directory as your code and name it ``simulaqron_network.json``.
179+
Alternatively, load a custom path in your Python code::
140180

141181
from simulaqron.settings import network_config
142-
...
143182

144183
network_config.read_from_file("/path/to/your/simulaqron_network.json")
145184

@@ -149,35 +188,37 @@ manually load this file in your python code::
149188
Network topologies
150189
------------------
151190

152-
Each network configuration contains an entry named ``"topology"``, which can be used to define the topology of the
153-
network. This could for example be::
191+
Each network configuration contains a ``"topology"`` entry that defines which nodes can communicate
192+
quantum information with each other. Setting it to ``null`` means fully connected (every node can reach
193+
every other node).
194+
195+
A custom topology is specified as a dictionary of adjacency lists::
154196

155197
{
156198
"Alice": ["Bob"],
157-
"Bob": ["Alice", "Charlie"]
199+
"Bob": ["Alice", "Charlie"],
158200
"Charlie": ["Bob"]
159201
}
160202

161-
describing a network topology where Alice is adjacent to Bob, Bob is adjacent to Alice and Charlie and Charlie is
162-
adjacent to Bob.
203+
This describes a network where Alice is adjacent to Bob, Bob is adjacent to Alice and Charlie, and Charlie
204+
is adjacent to Bob.
163205

164-
.. note:: Undirected topologies are also supported. That is, networks where for example Alice can send a qubit to
165-
Bob but Bob cannot send a qubit to Alice.
206+
.. note:: Directed topologies are also supported. For example, Alice can send a qubit to Bob but Bob
207+
cannot send a qubit to Alice.
166208

167209
---------------------------
168210
Generate network topologies
169211
---------------------------
170212

171-
The simulaqron tool is also capable of automatically generating certain well-known network topologies.
172-
The options for the automatically generated topologies are currently:
213+
SimulaQron can automatically generate certain well-known network topologies:
173214

174-
* `complete`: A fully connected. This is also used if the argument --topology is not used.
175-
* `ring`: A ring network, i.e. a connected topology where every node has exactly two neighbors.
176-
* `path`: A path network, i.e. a connected topology where every node has exactly two neighbors but there are no cycles.
177-
* `random_tree`: Generates a random tree, i.e. a topology without cycles.
178-
* `random_connected_{int}`: Generates a random connected graph with a specified number of edges. For example a random
179-
connected network on 10 nodes, can be specified as `random_connected_20`. Note that the number of edges for a network
180-
with :math:`n` nodes must be greater or equal to :math:`n-1` and less or equal to :math:`n(n-1)/1`.
215+
* ``complete``: Fully connected (default if no topology is specified)
216+
* ``ring``: Every node has exactly two neighbors, forming a cycle
217+
* ``path``: Every node has at most two neighbors, no cycles
218+
* ``random_tree``: A random tree (connected, no cycles)
219+
* ``random_connected_{int}``: A random connected graph with a specified number of edges (e.g.
220+
``random_connected_20`` for 20 edges). The number of edges must be between :math:`n-1` and
221+
:math:`n(n-1)/2` for :math:`n` nodes.
181222

182223
.. note:: Topology generation via the CLI is planned but not yet implemented. For now, specify topologies
183224
directly in the ``simulaqron_network.json`` file (see :ref:`network-topologies`).
@@ -190,25 +231,25 @@ The network that is then started might look like this:
190231
.. image:: figs/topology.png
191232
:width: 400px
192233
:align: center
193-
:alt: Programming SimulaQron Interfaces
234+
:alt: Example network topology
194235

195-
To create a custom topology, see section :ref: `network-topologies`.
236+
To create a custom topology, see section :ref:`network-topologies`.
196237

197238
--------------------------
198239
Starting multiple networks
199240
--------------------------
200241

201-
To run multiple networks at the same time you need to give them different names in the network configuration file,
202-
and then use the names to start them by using the --name flag::
242+
To run multiple networks at the same time, give them different names in the network configuration file
243+
and use the ``--name`` flag::
203244

204-
simulaqron start --name NETWORK
245+
simulaqron start --name NETWORK --nodes Alice,Bob
205246

206-
To stop a network with a specific name type::
247+
To stop a specific network::
207248

208249
simulaqron stop --name NETWORK
209250

210-
.. note:: By default the network name is "default". To have multiple networks running at the same time the nodes
211-
cannot use the same port numbers.
251+
.. note:: By default the network name is "default". To have multiple networks running at the same time the
252+
nodes cannot use the same port numbers.
212253

213-
The JSON configuration file can hold more than one network configuration. To check how to specify such configuration,
214-
please check the :ref: `networkConfig`.
254+
The JSON configuration file can hold more than one network configuration. See :ref:`networkConfig` above for
255+
an example with multiple networks.

0 commit comments

Comments
 (0)