simulaqron package

Subpackages

Submodules

simulaqron.cli module

class simulaqron.cli.RunningSimulaQronDaemon(pidfile: Path)[source]

Bases: RunDaemon

SimulaQronDaemon class used to represent SimulaQron daemons that are already running. This class is useful to stop the already-running daemons without needed to read all the required configurations.

Initialize the daemon with a pidfile.

class simulaqron.cli.SimulaQronDaemon(pidfile: Path, name: str, nodes: List[str], network_config_file: Path)[source]

Bases: RunDaemon

Daemon process that runs a SimulaQron network in the background.

This daemon spawns virtual nodes and QNodeOS servers for each node in the network configuration. It runs until explicitly stopped.

Parameters:
  • pidfile (Path) – Path to the PID file used to track the daemon process.

  • name (str) – Name of the network (e.g., ‘default’).

  • nodes (List[str]) – List of node names to start (e.g., [‘Alice’, ‘Bob’]).

  • network_config_file (Path) – Path to the network configuration file.

run()[source]

Starts all nodes defined in netsim’s config directory.

simulaqron.math module

simulaqron.math.assemble_qubit(realM: ndarray, imagM: ndarray) ndarray[source]

Reconstitute the qubit as array from its real and imaginary components given as a list.

Parameters:
  • realM (np.ndarray) – Real component of the qubit.

  • imagM (np.ndarray) – Imaginary component of the qubit.

Returns:

Assembled qubit as vector of complex numbers.

Return type:

np.array

simulaqron.network module

class simulaqron.network.Network(nodes: List[str], network_config_file: Path, network_name: str = 'default')[source]

Bases: object

Used to spin up a simulated network. This class uses the network configuration loaded in the global network_config object and starts the nodes mentioned in the constructor of this class.

Parameters:
  • nodes (List[str]) – A list of strings with the node names to start.

  • network_config_file (str) – Path to network config file (required).

  • network_name (str) – The name of network to start. Defaults to “default”.

property processes: List[ForkProcess]
property running: bool

Checks whether the network up and running.

Returns:

True if the network up and running. False otherwise

Return type:

bool

start(wait_until_running=False)[source]

Starts the network. The boolean flag ‘wait_until_running’ can be used whether the call to this method should blog until the all processes are running and are connected or not. :param wait_until_running: bool

stop()[source]

Stops the network.

simulaqron.network.construct_topology_config(topology: str | Dict | None, nodes: List[str]) Dict[str, List[str]][source]

Constructs a dictionary that maps the node names with their neighbours, representing a network topology.

Parameters:
  • topology (str | Dict) – The type of topology to generate. Should be one of the following: None, ‘complete’, ‘ring’, ‘random_tree’.

  • nodes (List[str]) – List of the names of the nodes.

Returns:

A dictionary where keys are the names of the nodes and values are a list of strings of their neighbors

Return type:

Dict[str, List[str]]

simulaqron.network.get_random_connected(nodes: List[str], nr_edges: int) Dict[str, List[str]][source]

Constructs a dictionary describing a random connected graph with a specified number of edges, with the name of the vertices are taken from the ‘nodes’

Parameters:
  • nodes (List[str]) – Name of the nodes to be used

  • nr_edges (int) – The number of edges that the graph should have.

Returns:

A dictionary where keys are the names of the nodes and values are a list of strings of their neighbors

Return type:

Dict[str, List[str]]

simulaqron.network.get_random_tree(nodes: List[str]) Dict[str, List[str]][source]

Constructs a dictionary describing a random tree, with the name of the vertices are taken from the ‘nodes’

Parameters:

nodes (List[str]) – Name of the nodes to be used

Returns:

A dictionary where keys are the names of the nodes and values are a list of strings of their neighbors

Return type:

Dict[str, List[str]]

simulaqron.reactor module

simulaqron.sim_util module

simulaqron.sim_util.get_qubit_state(qubit: Qubit, reduced_dm: bool = True) ndarray[source]

Get the state of the qubit, only possible in simulation and can be used for debugging.

Note

The function gets the current state of the qubit(s). So make sure the subroutine is flushed before calling the method.

Parameters:
  • qubit (Qubit) – The qubit(s) to get the state of.

  • reduced_dm (bool) – Unused; declared to keep compatibility with other simulation engines

Returns:

The state as a density matrix.

Return type:

np.array

Module contents