Skip to content

Commit b018d94

Browse files
committed
Update documentation. Fix broken internal links when building the documentation.
1 parent d2116b3 commit b018d94

21 files changed

Lines changed: 216 additions & 119 deletions

docs/ConfNodes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SimulaQron uses two configuration files:
55

66
* ``simulaqron_network.json`` — defines nodes, their socket ports, and network topology (described on this page)
77
* ``simulaqron_settings.json`` — configures the simulation backend, timeouts, and other settings
8-
(see the Settings section in `Getting Started <GettingStarted.rst>`_)
8+
(see the Settings section in :ref:`Configuring Settings <settings>`)
99

1010
-------------------------------------
1111
Running all nodes on a single machine
@@ -57,7 +57,7 @@ Each example in ``examples/new-sdk/`` and ``examples/nativeMode/`` includes a ``
5757
the SimulaQron backend and launches the node programs. This is the easiest way to try an example::
5858

5959
cd examples/new-sdk/corrRNG
60-
sh run.sh
60+
bash run.sh
6161

6262
The ``run.sh`` script reads the ``simulaqron_network.json`` and ``simulaqron_settings.json`` in the example
6363
directory, so each example is self-contained.
@@ -229,7 +229,7 @@ SimulaQron can automatically generate certain well-known network topologies:
229229
:math:`n(n-1)/2` for :math:`n` nodes.
230230

231231
.. note:: Topology generation via the CLI is planned but not yet implemented. For now, specify topologies
232-
directly in the ``simulaqron_network.json`` file (see `Network topologies`_ below).
232+
directly in the ``simulaqron_network.json`` file (see `Network topologies`_ above).
233233

234234
Along with setting up the network with the specified topology a .png figure is also generated and stored as
235235
config/topology.png. This is useful if a random network is used, to easily visualize the network used.
@@ -259,5 +259,5 @@ To stop a specific network::
259259
.. note:: By default the network name is "default". To have multiple networks running at the same time the
260260
nodes cannot use the same port numbers.
261261

262-
The JSON configuration file can hold more than one network configuration. See `Configuring the network`_ above for
263-
an example with multiple networks.
262+
The JSON configuration file can hold more than one network configuration. See `Writing the JSON config manually`_
263+
above for an example with multiple networks.

docs/Examples.rst

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SimulaQron Programming Examples
2-
================================
2+
===============================
33

44
SimulaQron offers three ways to write quantum network programs, from highest-level to lowest-level:
55

@@ -17,38 +17,57 @@ SimulaQron offers three ways to write quantum network programs, from highest-lev
1717
directly to SimulaQron's virtual quantum nodes. This is Python-specific and more verbose,
1818
but gives full control over the simulation backend.
1919

20-
The examples below assume that you have already made your way through `Getting Started <GettingStarted.rst>`_:
21-
you have the virtual node servers up and running.
20+
.. _get-examples:
21+
22+
-----------------------
23+
How to get the examples
24+
-----------------------
25+
26+
The code of the examples can be found in `SimulaQron GitHub repository <https://github.com/SoftwareQuTech/SimulaQron>`_.
27+
Clone this repository using ``git``::
28+
29+
git clone https://github.com/SoftwareQuTech/SimulaQron.git
30+
31+
All the examples can be found in the ``examples`` folder.
32+
33+
When running one of the examples mentioned below, we assume that you have already made your way through
34+
:doc:`Getting Started <GettingStarted>` and you have the virtual node servers up and running.
35+
36+
.. _new-sdk-examples:
2237

2338
-----------------
2439
New SDK examples
2540
-----------------
2641

27-
* `Overview <new-sdk/Overview.rst>`_ — Key concepts: ``NetQASMConnection``, ``EPRSocket``, ``flush()``, file structure
28-
* `Template <new-sdk/Template.rst>`_ — Getting started: single-node and client-server templates
29-
* `CorrRNG <new-sdk/CorrRNG.rst>`_ — EPR pairs between two nodes, correlated measurement
30-
* `Teleport <new-sdk/Teleport.rst>`_ — Quantum teleportation with classical correction messages
31-
* `ExtendGHZ <new-sdk/ExtendGHZ.rst>`_ — Three-party entanglement, multiple EPR sockets
32-
* `MidCircuitLogic <new-sdk/MidCircuitLogic.rst>`_ — Multiple ``flush()`` calls for mid-circuit classical decisions
42+
* :doc:`Overview <new-sdk/Overview>` — Key concepts: ``NetQASMConnection``, ``EPRSocket``, ``flush()``, file structure
43+
* :doc:`Template <new-sdk/Template>` — Getting started: single-node and client-server templates
44+
* :doc:`CorrRNG <new-sdk/CorrRNG>` — EPR pairs between two nodes, correlated measurement
45+
* :doc:`Teleport <new-sdk/Teleport>` — Quantum teleportation with classical correction messages
46+
* :doc:`ExtendGHZ <new-sdk/ExtendGHZ>` — Three-party entanglement, multiple EPR sockets
47+
* :doc:`MidCircuitLogic <new-sdk/MidCircuitLogic>` — Multiple ``flush()`` calls for mid-circuit classical decisions
48+
49+
.. _event-based-examples:
3350

3451
---------------------
3552
Event-based examples
3653
---------------------
3754

38-
* `Overview <event-based/Overview.rst>`_ — Event-based programming model and state machines
39-
* `PingPong <event-based/PingPong.rst>`_ — Classical ping-pong between two nodes
40-
* `PolitePingPong <event-based/PolitePingPong.rst>`_ — State-machine message dispatch pattern
41-
* `QuantumCorrRNG <event-based/QuantumCorrRNG.rst>`_ — Quantum correlated RNG with state machine
42-
* `QuantumCorrRNGVerified <event-based/QuantumCorrRNGVerified.rst>`_ — Correlated RNG with verification protocol
55+
* :doc:`Overview <event-based/Overview>` — Event-based programming model and state machines
56+
* :doc:`PingPong <event-based/PingPong>` — Classical ping-pong between two nodes
57+
* :doc:`PolitePingPong <event-based/PolitePingPong>` — State-machine message dispatch pattern
58+
* :doc:`QuantumCorrRNG <event-based/QuantumCorrRNG>` — Quantum correlated RNG with state machine
59+
* :doc:`QuantumCorrRNGVerified <event-based/QuantumCorrRNGVerified>` — Correlated RNG with verification protocol
60+
61+
.. _native-mode-examples:
4362

4463
---------------------
4564
Native mode examples
4665
---------------------
4766

48-
* `Template <native-mode/Template.rst>`_ — Template for programming in native (Twisted) mode
49-
* `CorrRng <native-mode/CorrRng.rst>`_ — Correlated randomness using native mode
50-
* `Teleport <native-mode/Teleport.rst>`_ — Teleportation using native mode
51-
* `GraphState <native-mode/GraphState.rst>`_ — Distributing a graph state across four nodes
67+
* :doc:`Template <native-mode/Template>` — Template for programming in native (Twisted) mode
68+
* :doc:`CorrRng <native-mode/CorrRng>` — Correlated randomness using native mode
69+
* :doc:`Teleport <native-mode/Teleport>` — Teleportation using native mode
70+
* :doc:`GraphState <native-mode/GraphState>` — Distributing a graph state across four nodes
5271

5372
.. toctree::
5473
:hidden:

docs/GettingStarted.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ you can install the *deadsnakes* repository to gain access to some specific pyth
2121

2222
sudo add-apt-repository -y "ppa:deadsnakes/ppa"
2323

24-
After adding the repository, you can install the *full* version of python, including the development package and the ::
24+
After adding the repository, you can install the *full* version of python, including the development package::
2525

2626
sudo apt-get install python3.12-full python3.12-dev
2727

@@ -56,10 +56,10 @@ Testing a simple example
5656
------------------------
5757

5858
Before delving into how to write any program yourself, let's first simply run one of the existing examples.
59-
Remember from the Overview that SimulaQron has two parts: the first are the virtual node servers that simulate
60-
the hardware at each node as well as the quantum communication between them in a transparent manner.
59+
Remember from the :doc:`Overview<Overview>` that SimulaQron has two parts: the first are the virtual node servers
60+
that simulate the hardware at each node as well as the quantum communication between them in a transparent manner.
6161
The second are the applications themselves which can be written in two ways: the direct way is to use the native
62-
mode using the Python Twisted framework connecting to the virtual node servers (see `Examples <Examples.rst>`_),
62+
mode using the Python Twisted framework connecting to the virtual node servers (see :ref:`Native mode examples <native-mode-examples>`),
6363
and the recommended way is to use the NetQASM library that calls the virtual nodes via the NetQASM interface.
6464
We will here illustrate how to use SimulaQron with the NetQASM library.
6565

@@ -81,7 +81,7 @@ the backend of SimulaQron simply type::
8181
responsibility for problems caused by SimulaQron.
8282

8383
For more information on what ``simulaqron start`` does, how to change the nodes and the ports of the network,
84-
the topology etc, see `Configuring the Network <ConfNodes.rst>`_.
84+
the topology etc, see :doc:`Configuring the Network <ConfNodes>`.
8585

8686
To stop the backend, simply type::
8787

@@ -99,7 +99,8 @@ Running a protocol
9999
^^^^^^^^^^^^^^^^^^^
100100

101101
Having started the virtual quantum nodes as above, let us now run a simple test application, which already illustrates
102-
some of the aspects in realizing protocols.
102+
some of the aspects in realizing protocols. Before proceeding, please download the SimulaQron examples as shown in the
103+
:ref:`How to get the examples<get-examples>` section.
103104
Our objective will be to realize the following protocol which will generate 1 shared random bit between Alice and Bob.
104105
Evidently, there would be classical means to achieve this trivial task chosen for illustration.
105106

@@ -108,11 +109,12 @@ Evidently, there would be classical means to achieve this trivial task chosen fo
108109

109110
* Both Alice and Bob measure their respective qubits to obtain a classical random number :math:`x \in \{0,1\}`.
110111

111-
The examples can be found in ``examples/new-sdk/`` (see `Examples <Examples.rst>`_ for the full list).
112-
Before seeing how this example works, let us simply run the code::
112+
We will follow the example located in ``examples/new-sdk/coorRNG`` (see :ref:`New SDK Examples <new-sdk-examples>` for
113+
the full list). Before seeing how this works, let us simply run the code (assuming you're already in the ``SimulaQron``
114+
folder cloned from GitHub)::
113115

114116
cd examples/new-sdk/corrRNG
115-
sh run.sh
117+
bash run.sh
116118

117119
You should be seeing the following two lines::
118120

@@ -125,21 +127,21 @@ going on here? Let us first look at how we will realize the example by making an
125127
* Alice and Bob generate one EPR pair, that is, two maximally entangled qubits :math:`A` and :math:`B` of the form
126128
:math:`|\Psi\rangle_{AB} = \frac{1}{\sqrt{2}} \left(|0\rangle_A |0\rangle_B + |1\rangle_A |1\rangle_B\right)`
127129

128-
* Alice and Bob are informed of the identifiers of the qubits and are informed that entanglement was generated.
129-
130130
* Both Alice and Bob measure their respective qubits to obtain a classical random number :math:`x \in \{0,1\}`.
131131

132-
While the task we want to realize here is completely trivial, the addition of step 3 does however already highlight a
133-
range of choices on how to realize step 3 and the need to find good abstractions to allow easy application development.
134-
One way to realize step 3 would be to hardwire Alice's and Bob's measurements: if the hardware can identify the
132+
While the task we want to realize here is completely trivial, the addition of step 2 does however already highlight a
133+
range of choices on how to realize step 2 and the need to find good abstractions to allow easy application development.
134+
One way to realize step 2 would be to hardwire Alice's and Bob's measurements: if the hardware can identify the
135135
correct qubits from the entanglement generation, then we could instruct it to measure it immediately without asking
136136
for a notification from the entanglement generation process. It is clear that in a network that is a bit larger than
137-
our tiny three node setup, identifying the right setup requires a link between the underlying qubits and classical
137+
our tiny two node setup, identifying the right setup requires a link between the underlying qubits and classical
138138
control information: this is the objective of the classical/quantum combiner.
139139

140140
The script ``run.sh`` executes the following two python scripts::
141141

142-
#!/bin/sh
142+
#!/usr/bin/env bash
143+
144+
# Some code to start SimulaQron backend
143145

144146
python3 aliceTest.py
145147
python3 bobTest.py &
@@ -188,7 +190,7 @@ Similarly the core of ``bobTest.py`` is::
188190
m1_val = int(m1)
189191
sim_conn.close()
190192

191-
For further examples, see `Examples <Examples.rst>`_ and `The NetQASM Interface <NetQASM.rst>`_ for the full SDK reference.
193+
For further examples, see :doc:`Examples <Examples>` and :doc:`The NetQASM Interface <NetQASM>` for the full SDK reference.
192194

193195
.. _settings:
194196

@@ -207,7 +209,7 @@ To set a setting, for example to use the projectQ backend, type::
207209
This will create a file named ``simulaqron_settings.json`` in the current folder. This new file contains a full set of
208210
simulaqron configuration, including the setting that was just configured (using the `projectq` backend, in the example).
209211

210-
It is also possible to manually create this` `simulaqron_settings.json`` file with any text editor::
212+
It is also possible to manually create this ``simulaqron_settings.json`` file with any text editor::
211213

212214
{
213215
"backend": "projectq",
@@ -247,7 +249,7 @@ implement using simulaqron.
247249
it, set the settings and start it again.
248250

249251
It is also possible to create the default SimulaQron network configuration in the current folder. Check the
250-
`Configuring the Network <ConfNodes.rst>`_ document to check how to achieve this.
252+
:doc:`Configuring the Network <ConfNodes>` document to check how to achieve this.
251253

252254
^^^^^^^^^^^^^^^^^^^
253255
Settings precedence
@@ -270,7 +272,7 @@ Settings Fields
270272
The SimulaQron settings file contains a set of fields to control the configurations of the SimulaQron simulation:
271273

272274
* ``max_qubit``: Maximum number of qubits to simulate on the Virtual Node.
273-
* ``max_registers``: Maximmum number of registers to use in the Virtual Node.
275+
* ``max_registers``: Maximum number of registers to use in the Virtual Node.
274276
* ``conn_retry_time``: Number of seconds to wait between connection retries.
275277
* ``conn_max_retries``: Maximum number of times to retry a connection before failing the whole execution.
276278
* ``recv_timeout``: Maximum number of milliseconds to wait for the messages when trying to create EPR pairs.

docs/NetQASM.rst

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ The NetQASM interface
22
=====================
33

44
SimulaQron applications are written using the **NetQASM SDK**. This page describes the core concepts and
5-
programming model. For complete working examples, see `Examples <Examples.rst>`_.
5+
programming model. For complete working examples, see :doc:`Examples <Examples>`.
66

77
------------
88
Installation
99
------------
1010

11-
The NetQASM library is included as a dependency of SimulaQron. Installing SimulaQron automatically installs
12-
everything you need::
13-
14-
pip3 install simulaqron
11+
The NetQASM library is included as a dependency of SimulaQron. For the instructions how to install SimulaQron
12+
please check the :doc:`Getting Started<GettingStarted>` section.
1513

1614
--------------
1715
Core concepts
@@ -94,14 +92,16 @@ You can call ``flush()`` multiple times on the same connection. This enables **m
9492
other_qubit.X() # conditional correction
9593
conn.flush()
9694

97-
See the mid-circuit logic example in `Examples <Examples.rst>`_ for a full demonstration.
95+
See the mid-circuit logic example in :doc:`Examples <Examples>` for a full demonstration.
9896

9997
---------------
10098
Minimal example
10199
---------------
102100

103101
A single-node program that creates a qubit, applies a Hadamard gate, and measures::
104102

103+
from netqasm.runtime.settings import set_simulator
104+
set_simulator("simulaqron")
105105
from netqasm.sdk.external import NetQASMConnection
106106
from netqasm.sdk import Qubit
107107

@@ -113,6 +113,9 @@ A single-node program that creates a qubit, applies a Hadamard gate, and measure
113113
print("Measurement outcome:", int(m))
114114
conn.close()
115115

116+
If you want to run this minimal example, remember to start the SimulaQron backend before executing the code:
117+
``simulaqron start``.
118+
116119
--------------------
117120
Two-node EPR example
118121
--------------------
@@ -139,7 +142,9 @@ Alice and Bob generate an EPR pair and each measure their qubit to get correlate
139142
print("Bob:", int(m))
140143
conn.close()
141144

142-
Both sides will print the same random number (0 or 1), demonstrating quantum correlation.
145+
Both sides will print the same random number (0 or 1), demonstrating quantum correlation. A full working example
146+
of this can be found in the ``new-sdk/corrRNG`` example. See the :doc:`Correlated RNG<new-sdk/CorrRNG>` section for
147+
more details.
143148

144149
-----------------------
145150
Classical communication
@@ -176,18 +181,19 @@ receiving classical messages::
176181
conn.flush()
177182
conn.close()
178183

179-
See the `Template <new-sdk/Template.rst>`_ page for how to set up the client and server, and the teleportation example
180-
for a complete two-node program with classical messaging.
184+
See the :doc:`Template <new-sdk/Template>` page for how to set up the client and server, and the
185+
:doc:`teleportation example <new-sdk/Teleport>` for a complete two-node program with classical messaging.
181186

182187
-----------------------
183188
Configuration
184189
-----------------------
185190

186191
Each program needs two configuration files in its directory:
187192

188-
* ``simulaqron_network.json`` — defines the nodes and their socket ports. See `Configuring the Network <ConfNodes.rst>`_ for details.
193+
* ``simulaqron_network.json`` — defines the nodes and their socket ports. See :doc:`Configuring the Network <ConfNodes>`
194+
for details.
189195
* ``simulaqron_settings.json`` — configures the simulation backend and other settings. See the
190-
Settings section in `Getting Started <GettingStarted.rst>`_.
196+
Settings section in :doc:`Getting Started <GettingStarted>`.
191197

192198
The ``stabilizer`` backend is used by default and is recommended unless you need non-Clifford gates (use
193199
``qutip`` in that case).
@@ -196,6 +202,6 @@ The ``stabilizer`` backend is used by default and is recommended unless you need
196202
Further reading
197203
-----------------------
198204

199-
* `Examples <Examples.rst>`_ — complete working examples from simple to complex
200-
* `New SDK Overview <new-sdk/Overview.rst>`_ — detailed SDK concepts and file structure
205+
* :doc:`Examples <Examples>` — complete working examples from simple to complex
206+
* :doc:`New SDK Overview <new-sdk/Overview>` — detailed SDK concepts and file structure
201207
* `NetQASM library documentation <https://netqasm.readthedocs.io/en/latest/>`_

docs/Overview.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ In the light of the alternate interface below it may appear inefficient to expor
1515
the purpose of SimulaQron is precisely to explore and play with higher layer abstractions on top of any hardware, or
1616
its simulated version, SimulaQron. As such it is best to think of SimulaQron as a piece of simulated hardware with its
1717
own native interface, which we may first abstract into a higher level command language for programming. Examples of
18-
how to program SimulaQron in native mode can be found in `Examples <Examples.rst>`_.
18+
how to program SimulaQron in native mode can be found in :doc:`Examples <Examples>`.
1919

2020
The second way to run applications is via a higher level interface, the NetQASM interface. If you want your
2121
applications to later use real quantum hardware more easily instead of SimulaQron, then this is the interface to use.
22-
Examples of how to program using the NetQASM can be found in `The NetQASM Interface <NetQASM.rst>`_.
22+
Examples of how to program using the NetQASM can be found in :doc:`The NetQASM Interface <NetQASM>`.
2323

2424
.. image:: figs/netqasm_architecture.png
2525
:width: 500px

0 commit comments

Comments
 (0)