QuantumNetworkSession#

class QuantumNetworkSession(name, socket_ip, port=None)[source]#

This class allows using Qrisps high-level programming interface to interact with QuantumNetworks. As an inheritor of the QuantumSession class, we can create QuantumVariables with it which can then be sent to other participators of the QuantumNetwork.

Note that get_measurement calls are also realized by the single-shot simulator. For more information on this check the documentation of the run method of the QuantumNetworkClient class.

Parameters
namestr

A nickname such as “Alice” or “Bob”, which is used to direct the communication of other users to you.

socket_ipstr

The IP of the QuantumNetworkServer to connect to.

portint

The port of the QuantumNetworkServer to connect to. The default is 7070.

Examples

We create a QuantumNetworkServer and connect a QuantumNetworkSession to it.

>>> from qrisp.quantum_network import QuantumNetworkServer, QuantumNetworkSession
>>> example_server = QuantumNetworkServer(socket_ip = "127.0.0.1", background = True)
>>> example_server.start()
>>> alice_session = QuantumNetworkSession(socket_ip = "127.0.0.1", port = 7070, name = "alice")

Now we can create QuantumVariables as we are used to

>>> from qrisp import QuantumFloat
>>> qf = QuantumFloat(4, 5, qs = alice_session)

Methods#

As an inheritor of QuantumSession, all the methods from this class work on QuantumNetworkSession too.

QuantumNetworkSession.send_qv(qv, recipient)

Sends a QuantumVariable to another participant of the network.

QuantumNetworkSession.update()

This updates the inbox attribute and returns the received QuantumVariables.