@@ -5,8 +5,8 @@ Getting started
55Setup
66-----
77
8- SimulaQron requires `Python 3.12 <https://python.org/ >`_ along with the packages *cqc *, *twisted *, *numpy *, *scipy *,
9- *networkx *, *flake8 *, * click * and *daemons *.
8+ SimulaQron requires `Python 3.12 <https://python.org/ >`_ along with the packages *netqasm *, *twisted *, *numpy *, *scipy *,
9+ *networkx *, *click * and *daemons *.
1010
1111^^^^^^^^^^^^^^^^^^^^^^
1212Installation using pip
@@ -41,14 +41,13 @@ interactive python console by typing `python3` and the::
4141Testing a simple example
4242------------------------
4343
44- Before delving into how to write any program yourself, let's first simply run one of the existing examples when
45- programming SimulaQron through the Python library (see https://softwarequtech.github.io/CQC-Python/examples.html).
46- Remember from the Overview that SimulaQron has two parts: the first are the virtual node servers that act simulate
44+ Before delving into how to write any program yourself, let's first simply run one of the existing examples.
45+ Remember from the Overview that SimulaQron has two parts: the first are the virtual node servers that simulate
4746the hardware at each node as well as the quantum communication between them in a transparent manner.
48- The second are the applications themselves which can be written in two ways, the direct way is to use the native
49- mode using the Python Twisted framework connecting to the virtual node servers, see :doc: `Examples `.
50- The recommended way however is the use the NetQASM library that calls the virtual nodes by making use of the
51- çclassical/quantum combiner interface. We will here illustrate how to use SimulaQron with the NetQASM library.
47+ The second are the applications themselves which can be written in two ways: the direct way is to use the native
48+ mode using the Python Twisted framework connecting to the virtual node servers ( see :doc: `Examples `),
49+ and the recommended way is to use the NetQASM library that calls the virtual nodes via the NetQASM interface.
50+ We will here illustrate how to use SimulaQron with the NetQASM library.
5251
5352^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5453Starting the SimulaQron backend
@@ -94,18 +93,16 @@ Evidently, there would be classical means to achieve this trivial task chosen fo
9493
9594* Both Alice and Bob measure their respective qubits to obtain a classical random number :math: `x \in \{ 0 ,1 \}`.
9695
97- .. warning :: Update the link references and the names of the examples (NetQASM vs pythonLib)
98-
99- The examples can be found in the repo `pythonLib <https://github.com/SoftwareQuTech/CQC-Python >`_.
96+ The examples can be found in ``examples/new-sdk/ `` (see :doc: `Examples ` for the full list).
10097Before seeing how this example works, let us simply run the code::
10198
102- cd examples/nativeMode /corrRNG
99+ cd examples/new-sdk /corrRNG
103100 sh run.sh
104101
105102You should be seeing the following two lines::
106103
107- App Alice: Measurement outcome is: 0/1
108- App Bob: Measurement outcome is: 0/1
104+ Alice: My Random Number is ' 0/1'
105+ Bob: My Random Number is ' 0/1'
109106
110107Note that the order of these two lines may differ, as it does not matter who measures first. So what is actually
111108going on here? Let us first look at how we will realize the example by making an additional step (3) explicit:
@@ -131,47 +128,49 @@ The script run.sh executes the following two python scripts::
131128
132129Let us now look at the programs for Alice and Bob.
133130
134- We first initialize an object of the class ``NetQASMConnection `` which will do all the communication to the virtual
135- through the NetQASM interface.
136- Qubits can then be created by initializing a qubit-object, which takes a ``NetQASMConnection `` as an input.
137- On these qubits operations can be applied and they can also be sent to other nodes in the network by use of the
138- ``NetQASMConnection ``. The full code in aliceTest.py is::
139-
140- # Create an EPR Socket between "Alice" and "Bob"
141- epr_socket = EPRSocket("Alice", "Bob")
142- # Initialize the connection
143- with NetQASMConnection("Alice", epr_sockets=[epr_socket]) as Alice:
144- # Create an EPR pair
145- q = epr_socker.create_keep("Bob", number=1)[0]
146-
147- # Measure qubit
148- m=q.measure()
149- to_print="App {}: Measurement outcome is: {}".format(Alice.name,m)
150- print("|"+"-"*(len(to_print)+2)+"|")
151- print("| "+to_print+" |")
152- print("|"+"-"*(len(to_print)+2)+"|")
153-
154- Similarly the code in bobTest.py read::
155-
156- # Create an EPR Socket between "Bob" and "Alice"
157- epr_socket = EPRSocket("Bob", "Alice")
158- # Initialize the connection
159- with NetQASMConnection("Bob", epr_sockets=[epr_socket]) as Bob:
160-
161- # Receive qubit
162- q=epr_socker.receive_keep("Alice")[0]
163-
164- # Measure qubit
165- m=q.measure()
166- to_print="App {}: Measurement outcome is: {}".format(Bob.name,m)
167- print("|"+"-"*(len(to_print)+2)+"|")
168- print("| "+to_print+" |")
169- print("|"+"-"*(len(to_print)+2)+"|")
170-
171- .. warning :: Update the link references and the names of the examples (NetQASM vs pythonLib)
172-
173- For further examples, see the examples/ folder and for the docs of the Python library see
174- https://softwarequtech.github.io/CQC-Python/index.html.
131+ We first create a ``NetQASMConnection `` which handles all communication with the local quantum backend.
132+ An ``EPRSocket `` is used to create or receive entangled qubit pairs with a remote node.
133+ The key pattern is: queue operations, call ``flush() `` to execute them, then read results with ``int(m) ``.
134+
135+ The core of aliceTest.py is::
136+
137+ epr_socket = EPRSocket("Bob")
138+
139+ # sim_conn is our connection to the quantum backend (SimulaQron), not to Bob.
140+ sim_conn = NetQASMConnection("Alice", epr_sockets=[epr_socket])
141+
142+ # Create an entangled qubit
143+ epr = epr_socket.create_keep()[0]
144+
145+ # Measure it
146+ m1 = epr.measure()
147+
148+ # flush() executes all queued quantum operations and makes measurement
149+ # results available. Before flush(), m1 is just a future/promise.
150+ sim_conn.flush()
151+
152+ # int(m) extracts the measurement outcome — only valid after flush().
153+ m1_val = int(m1)
154+ sim_conn.close()
155+
156+ Similarly the core of bobTest.py is::
157+
158+ epr_socket = EPRSocket("Alice")
159+
160+ # sim_conn is our connection to the quantum backend (SimulaQron), not to Alice.
161+ sim_conn = NetQASMConnection("Bob", epr_sockets=[epr_socket])
162+
163+ # Receive an entangled qubit
164+ epr = epr_socket.recv_keep()[0]
165+
166+ # Measure it
167+ m1 = epr.measure()
168+
169+ sim_conn.flush()
170+ m1_val = int(m1)
171+ sim_conn.close()
172+
173+ For further examples, see :doc: `Examples ` and :doc: `NetQASM ` for the full SDK reference.
175174
176175.. _settings :
177176
0 commit comments