Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Network::INetwork< Time > Class Template Referenceabstract

The network interface. More...

#include <Network.h>

Inheritance diagram for Network::INetwork< Time >:

Public Types

using ExecuteResults = typename Circuits::Circuit<Time>::ExecuteResults
using SimulatorPair
using SimulatorsSet

Public Member Functions

virtual ~INetwork ()=default
 Destroy the INetwork object.
virtual size_t GetNumberOfGatesDistributedOrCut (const std::shared_ptr< Circuits::Circuit< Time > > &circuit) const =0
 Get the number of gates that span more than one host.
virtual void Execute (const std::shared_ptr< Circuits::Circuit< Time > > &circuit)=0
 Execute the circuit on the network.
virtual void ExecuteOnHost (const std::shared_ptr< Circuits::Circuit< Time > > &circuit, size_t hostId)=0
 Execute the circuit on the specified host.
virtual std::vector< double > ExecuteExpectations (const std::shared_ptr< Circuits::Circuit< Time > > &circuit, const std::vector< std::string > &paulis)=0
 Execute the circuit on the network and return the expectation values for the specified Pauli strings.
virtual std::vector< double > ExecuteOnHostExpectations (const std::shared_ptr< Circuits::Circuit< Time > > &circuit, size_t hostId, const std::vector< std::string > &paulis)=0
 Execute the circuit on the specified host and return the expectation values for the specified Pauli strings.
virtual ExecuteResults RepeatedExecute (const std::shared_ptr< Circuits::Circuit< Time > > &circuit, size_t shots=1000)=0
 Execute the circuit on the network, repeatedly.
ExecuteResults RepeatedExecuteCircuit (const Schedulers::ExecuteCircuit< Time > &executeCircuit)
 Execute the circuit on the network, repeatedly.
virtual ExecuteResults RepeatedExecuteOnHost (const std::shared_ptr< Circuits::Circuit< Time > > &circuit, size_t hostId, size_t shots=1000)=0
 Execute the circuit on the specified host, repeatedly.
ExecuteResults RepeatedExecuteCircuitOnHost (const Schedulers::ExecuteCircuit< Time > &executeCircuit, size_t hostId)
 Execute the circuit on the specified host, repeatedly.
virtual std::vector< ExecuteResultsExecuteScheduled (const std::vector< Schedulers::ExecuteCircuit< Time > > &circuits)=0
 Schedule and execute circuits on the network.
virtual void CreateSimulator (Simulators::SimulatorType simType=Simulators::SimulatorType::kQCSim, Simulators::SimulationType simExecType=Simulators::SimulationType::kMatrixProductState, size_t nrQubits=0)=0
 Create the simulator for the network.
virtual std::shared_ptr< Simulators::ISimulatorGetSimulator () const =0
 Get the simulator for the network.
virtual void Configure (const char *key, const char *value)=0
 Configures the network.
virtual void CreateScheduler (SchedulerType schType=SchedulerType::kNoEntanglementQubitsParallel)=0
 Create the scheduler for the network.
virtual std::shared_ptr< Schedulers::IScheduler< Time > > GetScheduler () const =0
 Get the scheduler for the network.
virtual const std::shared_ptr< IHost< Time > > GetHost (size_t hostId) const =0
 Get the host with the specified id.
virtual const std::shared_ptr< IController< Time > > GetController () const =0
 Get the controller for the network.
virtual Circuits::OperationStateGetState ()=0
 Get the classical state of the network.
virtual size_t GetNumHosts () const =0
 Get the number of hosts in the network.
virtual size_t GetNumQubits () const =0
 Get the number of qubits in the network.
virtual size_t GetNumQubitsForHost (size_t hostId) const =0
 Get the number of qubits in the network for the specified host.
virtual size_t GetNumNetworkEntangledQubits () const =0
 Get the number of qubits used for entanglement between hosts.
virtual size_t GetNumNetworkEntangledQubitsForHost (size_t hostId) const =0
 Get the number of qubits used for entanglement between hosts for the specified host.
virtual size_t GetNumClassicalBits () const =0
 Get the number of classical bits in the network.
virtual size_t GetNumClassicalBitsForHost (size_t hostId) const =0
 Get the number of classical bits in the network for the specified host.
virtual bool AreQubitsOnSameHost (size_t qubitId1, size_t qubitId2) const =0
 Check if the specified qubits are on the same host.
virtual bool AreClassicalBitsOnSameHost (size_t bitId1, size_t bitId2) const =0
 Check if the specified classical bits are on the same host.
virtual bool AreQubitAndClassicalBitOnSameHost (size_t qubitId, size_t bitId) const =0
 Check if the specified qubit and classical bit are on the same host.
virtual size_t GetHostIdForQubit (size_t qubitId) const =0
 Get the host id for the specified qubit.
virtual size_t GetHostIdForEntangledQubit (size_t qubitId) const =0
 Get the host id for the specified qubit used for entanglement between hosts.
virtual size_t GetHostIdForAnyQubit (size_t qubitId) const =0
 Get the host id for the specified qubit.
virtual size_t GetHostIdForClassicalBit (size_t classicalBitId) const =0
 Get the host id for the specified classical bit.
virtual std::vector< size_t > GetQubitsIds (size_t hostId) const =0
 Get the qubit ids for the specified host.
virtual std::vector< size_t > GetNetworkEntangledQubitsIds (size_t hostId) const =0
 Get the qubit ids used for entanglement between hosts for the specified host.
virtual std::vector< size_t > GetClassicalBitsIds (size_t hostId) const =0
 Get the classical bit ids for the specified host.
virtual std::vector< size_t > GetEntangledQubitMeasurementBitIds (size_t hostId) const =0
 Get the classical bit ids used for measurement of entanglement qubits between the hosts for the specified host.
virtual bool IsNetworkEntangledQubit (size_t qubitId) const =0
 Check if the specified qubit id is for a qubit used for entanglement between hosts.
virtual bool IsLocalOperation (const std::shared_ptr< Circuits::IOperation< Time > > &op) const =0
 Check if the circuit operation is local.
virtual bool IsDistributedOperation (const std::shared_ptr< Circuits::IOperation< Time > > &op) const =0
 Check if the circuit operation is distributed.
virtual bool OperatesWithNetworkEntangledQubit (const std::shared_ptr< Circuits::IOperation< Time > > &op) const =0
 Check if the circuit operation operates on the entanglement qubits between hosts.
virtual bool SendPacket (size_t fromHostId, size_t toHostId, const std::vector< uint8_t > &packet)=0
 Sends a packet between two hosts.
virtual bool IsEntanglingGate (const std::shared_ptr< Circuits::IOperation< Time > > &op) const =0
 Checks if a gate is an entangling gate.
virtual bool ExpectsClassicalBitFromOtherHost (const std::shared_ptr< Circuits::IOperation< Time > > &op) const =0
 Checks if a gate expects a classical bit from another host.
virtual size_t GetHostIdForClassicalControl (const std::shared_ptr< Circuits::IOperation< Time > > &op) const =0
 Get the host id where the classical control bit resides for a conditioned gate.
virtual bool IsEntanglementQubitBusy (size_t qubitId) const =0
 Check if the specified qubit used for entanglement between hosts is busy.
virtual bool AreEntanglementQubitsBusy (size_t qubitId1, size_t qubitId2) const =0
 Check if any of the two specified qubits used for entanglement between hosts are busy.
virtual void MarkEntangledQubitsBusy (size_t qubitId1, size_t qubitId2)=0
 Mark the pair of the specified qubits used for entanglement between hosts as busy.
virtual void MarkEntangledQubitFree (size_t qubitId)=0
 Mark the specified qubit used for entanglement between hosts as free.
virtual void ClearEntanglements ()=0
 Clear all entanglements between hosts in the network.
std::shared_ptr< INetwork< Time > > getptr ()
 Get a shared pointer to this object.
virtual NetworkType GetType () const =0
 Get the type of the network.
virtual std::shared_ptr< INetwork< Time > > Clone () const =0
 Clone the network.
virtual std::shared_ptr< Circuits::Circuit< Time > > GetDistributedCircuit () const =0
 Get the distributed circuit.
virtual void SetOptimizeSimulator (bool optimize=true)=0
 Allows using an optimized simulator.
virtual bool GetOptimizeSimulator () const =0
 Returns the 'optimize' flag.
virtual Simulators::SimulatorType GetLastSimulatorType () const =0
 Get the last used simulator type.
virtual Simulators::SimulationType GetLastSimulationType () const =0
 Get the last used simulation type.
virtual const SimulatorsSetGetSimulatorsSet () const =0
 Get the optimizations simulators set.
virtual void AddOptimizationSimulator (Simulators::SimulatorType type, Simulators::SimulationType kind)=0
 Adds a simulator to the simulators optimization set.
virtual void RemoveOptimizationSimulator (Simulators::SimulatorType type, Simulators::SimulationType kind)=0
 Removes a simulator from the simulators optimization set.
virtual void RemoveAllOptimizationSimulatorsAndAdd (Simulators::SimulatorType type, Simulators::SimulationType kind)=0
 Removes all simulators from the simulators optimization set and adds the one specified.
virtual bool OptimizationSimulatorExists (Simulators::SimulatorType type, Simulators::SimulationType kind) const =0
 Checks if a simulator exists in the optimization set.
virtual size_t GetMaxSimulators () const =0
 Get the maximum number of simulators that can be used in the network.
virtual void SetMaxSimulators (size_t maxSimulators)=0
 Set the maximum number of simulators that can be used in the network.
virtual std::vector< std::vector< std::string > > GetSubroutinesTextCode () const
 Get the text code that is executed on the hosts.
virtual std::shared_ptr< Simulators::ISimulatorChooseBestSimulator (const std::shared_ptr< Circuits::Circuit< Time > > &dcirc, size_t &counts, size_t nrQubits, size_t nrCbits, size_t nrResultCbits, Simulators::SimulatorType &simType, Simulators::SimulationType &method, std::vector< bool > &executed, bool multithreading=false, bool dontRunCircuitStart=false) const =0
 Choose the best simulator for the given circuit.

Detailed Description

template<typename Time = Types::time_type>
class Network::INetwork< Time >

The network interface.

The network interface. Must be derived from by the particular network implementations.

Template Parameters
TimeThe time type used for execution times.
See also
IHost
IController

Definition at line 56 of file Network.h.

Member Typedef Documentation

◆ ExecuteResults

template<typename Time = Types::time_type>
using Network::INetwork< Time >::ExecuteResults = typename Circuits::Circuit<Time>::ExecuteResults

Definition at line 58 of file Network.h.

◆ SimulatorPair

template<typename Time = Types::time_type>
using Network::INetwork< Time >::SimulatorPair
Initial value:
std::pair<Simulators::SimulatorType, Simulators::SimulationType>

Definition at line 59 of file Network.h.

◆ SimulatorsSet

template<typename Time = Types::time_type>
using Network::INetwork< Time >::SimulatorsSet
Initial value:
std::unordered_set<SimulatorPair, boost::hash<SimulatorPair>>

Definition at line 61 of file Network.h.

Constructor & Destructor Documentation

◆ ~INetwork()

template<typename Time = Types::time_type>
virtual Network::INetwork< Time >::~INetwork ( )
virtualdefault

Destroy the INetwork object.

Destroy the INetwork object. Virtual because this is an interface.

Member Function Documentation

◆ AddOptimizationSimulator()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::AddOptimizationSimulator ( Simulators::SimulatorType type,
Simulators::SimulationType kind )
pure virtual

Adds a simulator to the simulators optimization set.

Adds a simulator (if not already present) to the simulators optimization set.

Parameters
typeThe type of the simulator to add.
kindThe kind of the simulation to add.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ AreClassicalBitsOnSameHost()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::AreClassicalBitsOnSameHost ( size_t bitId1,
size_t bitId2 ) const
pure virtual

Check if the specified classical bits are on the same host.

Check if the specified classical are on the same host. This does not include the classical bits used for measuring the qubits used for entanglement between the hosts.

Returns
True if the specified qubits are on the same host, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ AreEntanglementQubitsBusy()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::AreEntanglementQubitsBusy ( size_t qubitId1,
size_t qubitId2 ) const
pure virtual

Check if any of the two specified qubits used for entanglement between hosts are busy.

Check if any of the two specified qubits used for entanglement between hosts are busy. This is used to check if the qubits are free in order to use them for creating an entanglement between hosts.

Parameters
qubitId1The id of the first qubit to check.
qubitId2The id of the second qubit to check.
Returns
True if any of the two specified qubits used for entanglement between hosts are busy, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ AreQubitAndClassicalBitOnSameHost()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::AreQubitAndClassicalBitOnSameHost ( size_t qubitId,
size_t bitId ) const
pure virtual

Check if the specified qubit and classical bit are on the same host.

Check if the specified qubit and classical bit are on the same host. This does not include the qubits used for entanglement between the hosts and the classical bits used for their measurement.

Returns
True if the specified qubit and classical bit are on the same host, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ AreQubitsOnSameHost()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::AreQubitsOnSameHost ( size_t qubitId1,
size_t qubitId2 ) const
pure virtual

Check if the specified qubits are on the same host.

Check if the specified qubits are on the same host. This does not include the qubits used for entanglement between the hosts.

Returns
True if the specified qubits are on the same host, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ ChooseBestSimulator()

template<typename Time = Types::time_type>
virtual std::shared_ptr< Simulators::ISimulator > Network::INetwork< Time >::ChooseBestSimulator ( const std::shared_ptr< Circuits::Circuit< Time > > & dcirc,
size_t & counts,
size_t nrQubits,
size_t nrCbits,
size_t nrResultCbits,
Simulators::SimulatorType & simType,
Simulators::SimulationType & method,
std::vector< bool > & executed,
bool multithreading = false,
bool dontRunCircuitStart = false ) const
pure virtual

Choose the best simulator for the given circuit.

Choose the best simulator for the given circuit, based on the number of qubits, number of classical bits, number of result classical bits and number of shots. The choice is made from the optimization simulators set.

Parameters
dcircThe distributed circuit to choose the simulator for.
countsThe number of shots to be executed.
nrQubitsThe number of qubits in the circuit.
nrCbitsThe number of classical bits in the circuit.
nrResultCbitsThe number of result classical bits in the circuit.
simTypeThe type of the chosen simulator.
methodThe kind of simulation of the chosen simulator.
executedA vector of bools marking the executed gates from the circuit (some of them might be executed when picking up the simulator - usually the gates from the beginning up to the measurements/resets).
multithreadingIf true, allows simulators to support multithreading (default is false). Multithreading will be set to false if multithreading is implemented at a higher level (multiple simulators in parallel).
Returns
A shared pointer to the chosen simulator.

◆ ClearEntanglements()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::ClearEntanglements ( )
pure virtual

Clear all entanglements between hosts in the network.

Clear all entanglements between hosts in the network. This marks all qubits used for entanglement between hosts as free. If the entanglements are explicitely coordinated in the network, all pairs of entangled qubits are released.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ Clone()

template<typename Time = Types::time_type>
virtual std::shared_ptr< INetwork< Time > > Network::INetwork< Time >::Clone ( ) const
pure virtual

Clone the network.

Clone the network in a pristine state.

Returns
A shared pointer to the cloned network.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ Configure()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::Configure ( const char * key,
const char * value )
pure virtual

Configures the network.

This function is called to configure the network (for example the simulator(s) used by the network.

Parameters
keyThe key of the configuration option.
valueThe value of the configuration.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ CreateScheduler()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::CreateScheduler ( SchedulerType schType = SchedulerType::kNoEntanglementQubitsParallel)
pure virtual

Create the scheduler for the network.

Creates the scheduler for the network. Call this only after the network topology has been set up. Should create the scheduler and set the network for it and any other necessary parameters.

Parameters
simTypeThe type of the scheduler to create.
See also
SchedulerType

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ CreateSimulator()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::CreateSimulator ( Simulators::SimulatorType simType = Simulators::SimulatorType::kQCSim,
Simulators::SimulationType simExecType = Simulators::SimulationType::kMatrixProductState,
size_t nrQubits = 0 )
pure virtual

Create the simulator for the network.

Creates the simulator for the network. Call this only after the network topology has been set up. Should create the simulator with the proper number of qubits for the whole network and also set up a 'classical state' for the whole network and distribute the qubits and cbits to the hosts. The nrQubits parameter is used internally to allocate a simulator for a single host only - if a circuit is executed on a single host. Let it to the default value - 0 - to allocate the number of qubits for the whole network.

Parameters
simTypeThe type of the simulator to create.
simExecTypeThe type of the simulation - statevector, composite, matrix product state, stabilizer, tensor network...
nrQubitsThe number of qubits to allocate for the simulator. Default is 0 - allocate the number of qubits for the whole network.
See also
Simulators::SimulatorType

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ Execute()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::Execute ( const std::shared_ptr< Circuits::Circuit< Time > > & circuit)
pure virtual

Execute the circuit on the network.

Execute the circuit on the network, using the controller for distributing the operations to the hosts. The base class functionality is used for circuit distribution, but then the distributed circuit is converted to netqasm. Ensure the quantum computing simulator and the netqasm virtual machines have been created before calling this.

Parameters
circuitThe circuit to execute.
See also
Circuits::Circuit

◆ ExecuteExpectations()

template<typename Time = Types::time_type>
virtual std::vector< double > Network::INetwork< Time >::ExecuteExpectations ( const std::shared_ptr< Circuits::Circuit< Time > > & circuit,
const std::vector< std::string > & paulis )
pure virtual

Execute the circuit on the network and return the expectation values for the specified Pauli strings.

Execute the circuit on the network, using the controller for distributing the operations to the hosts and return the expectation values for the specified Pauli strings. The base class functionality is used for circuit distribution, but then the distributed circuit is converted to netqasm. Ensure the quantum computing simulator and the netqasm virtual machines have been created before calling this.

Parameters
circuitThe circuit to execute.
paulisThe Pauli strings to measure the expectations for.
See also
Circuits::Circuit

◆ ExecuteOnHost()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::ExecuteOnHost ( const std::shared_ptr< Circuits::Circuit< Time > > & circuit,
size_t hostId )
pure virtual

Execute the circuit on the specified host.

Execute the circuit on the specified host. The circuit must fit on the host, otherwise an exception is thrown. The circuit will be mapped on the specified host, if its qubits start with indexing from 0 (if already mapped, the qubits won't be altered).

Parameters
circuitThe circuit to execute.
hostIdThe id of the host to execute the circuit on.
See also
Circuits::Circuit

◆ ExecuteOnHostExpectations()

template<typename Time = Types::time_type>
virtual std::vector< double > Network::INetwork< Time >::ExecuteOnHostExpectations ( const std::shared_ptr< Circuits::Circuit< Time > > & circuit,
size_t hostId,
const std::vector< std::string > & paulis )
pure virtual

Execute the circuit on the specified host and return the expectation values for the specified Pauli strings.

Execute the circuit on the specified host and return the expectation values for the specified Pauli strings. The circuit must fit on the host, otherwise an exception is thrown. The circuit will be mapped on the specified host, if its qubits start with indexing from 0 (if already mapped, the qubits won't be altered).

Parameters
circuitThe circuit to execute.
hostIdThe id of the host to execute the circuit on.
paulisThe Pauli strings to measure the expectations for.
See also
Circuits::Circuit

◆ ExecuteScheduled()

template<typename Time = Types::time_type>
virtual std::vector< ExecuteResults > Network::INetwork< Time >::ExecuteScheduled ( const std::vector< Schedulers::ExecuteCircuit< Time > > & circuits)
pure virtual

Schedule and execute circuits on the network.

Execute the circuits on the network, scheduling their execution and distributing the operations to the hosts. The way the circuits are distributed to the hosts depends on the specific interface implementations. The way they are scheduled depends on the network scheduler and parametrization.

Parameters
circuitsThe circuits to execute, along with the number of shots.
Returns
A vector of maps with the results of each circuit execution, where the key is the state as a vector of bools and the value is the number of times it was measured.
See also
Circuits::Circuit
ExecuteCircuit

◆ ExpectsClassicalBitFromOtherHost()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::ExpectsClassicalBitFromOtherHost ( const std::shared_ptr< Circuits::IOperation< Time > > & op) const
pure virtual

Checks if a gate expects a classical bit from another host.

It must be a conditional gate, conditioned on a classical bit from another host. Use it on already distributed gates, not on the original circuit.

Parameters
opThe operation to check.
Returns
True if the specified circuit operation needs a classical bit from another host, false otherwise.

◆ GetClassicalBitsIds()

template<typename Time = Types::time_type>
virtual std::vector< size_t > Network::INetwork< Time >::GetClassicalBitsIds ( size_t hostId) const
pure virtual

Get the classical bit ids for the specified host.

Get the classical bit ids for the specified host, excluding the one(s) used for measurement of entanglemen qubits between the hosts.

Parameters
hostIdThe id of the host to get the classical bit ids for.
Returns
A vector with the classical bit ids.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetController()

template<typename Time = Types::time_type>
virtual const std::shared_ptr< IController< Time > > Network::INetwork< Time >::GetController ( ) const
pure virtual

Get the controller for the network.

Gets a smart pointer to the controller for the network.

Returns
The controller for the network.
See also
IController

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetDistributedCircuit()

template<typename Time = Types::time_type>
virtual std::shared_ptr< Circuits::Circuit< Time > > Network::INetwork< Time >::GetDistributedCircuit ( ) const
pure virtual

Get the distributed circuit.

Get the distributed circuit. Execute() must be called first, otherwise the return would be nullptr.

Returns
The distributed circuit.
See also
Circuits::Circuit

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetEntangledQubitMeasurementBitIds()

template<typename Time = Types::time_type>
virtual std::vector< size_t > Network::INetwork< Time >::GetEntangledQubitMeasurementBitIds ( size_t hostId) const
pure virtual

Get the classical bit ids used for measurement of entanglement qubits between the hosts for the specified host.

Get the classical bit ids used for measurement of entanglement qubits between the hosts for the specified host.

Parameters
hostIdThe id of the host to get the classical bit ids for.
Returns
A vector with the classical bit ids.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetHost()

template<typename Time = Types::time_type>
virtual const std::shared_ptr< IHost< Time > > Network::INetwork< Time >::GetHost ( size_t hostId) const
pure virtual

Get the host with the specified id.

Get a smart pointer to the host that has the specified id.

Parameters
hostIdThe id of the host to get.
Returns
A smart pointer to the host that has the specified id.
See also
IHost

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetHostIdForAnyQubit()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetHostIdForAnyQubit ( size_t qubitId) const
pure virtual

Get the host id for the specified qubit.

Get the host id for the squbit, including the qubits used for entanglement between hosts.

Parameters
qubitIdThe id of the qubit to get the host id for.
Returns
The host id for the specified qubit.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetHostIdForClassicalBit()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetHostIdForClassicalBit ( size_t classicalBitId) const
pure virtual

Get the host id for the specified classical bit.

Get the host id for the specified classical bit, including the one(s) used for measurement of entanglement qubits between the hosts.

Parameters
classicalBitIdThe id of the classical bit to get the host id for.
Returns
The host id for the specified classical bit.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetHostIdForClassicalControl()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetHostIdForClassicalControl ( const std::shared_ptr< Circuits::IOperation< Time > > & op) const
pure virtual

Get the host id where the classical control bit resides for a conditioned gate.

It must be a conditional gate, conditioned on a qubit from another host. Use it on already distributed gates, not on the original circuit.

Parameters
opThe operation to find the host of the control bit.
Returns
The host id.

◆ GetHostIdForEntangledQubit()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetHostIdForEntangledQubit ( size_t qubitId) const
pure virtual

Get the host id for the specified qubit used for entanglement between hosts.

Get the host id for the specified qubit used for entanglement between hosts.

Parameters
qubitIdThe id of qubit the used for entanglement between hosts to get the host id for.
Returns
The host id for the specified qubit used for entanglement between hosts.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetHostIdForQubit()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetHostIdForQubit ( size_t qubitId) const
pure virtual

Get the host id for the specified qubit.

Get the host id for the specified qubit, excluding the qubits used for entanglement between hosts.

Parameters
qubitIdThe id of the qubit to get the host id for.
Returns
The host id for the specified qubit.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetLastSimulationType()

template<typename Time = Types::time_type>
virtual Simulators::SimulationType Network::INetwork< Time >::GetLastSimulationType ( ) const
pure virtual

Get the last used simulation type.

Get the last used simulation type.

Returns
The simulation type that was used last time.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetLastSimulatorType()

template<typename Time = Types::time_type>
virtual Simulators::SimulatorType Network::INetwork< Time >::GetLastSimulatorType ( ) const
pure virtual

Get the last used simulator type.

Get the last used simulator type.

Returns
The simulator type that was used last time.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetMaxSimulators()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetMaxSimulators ( ) const
pure virtual

Get the maximum number of simulators that can be used in the network.

Get the maximum number of simulators that can be used in the network. This is used to limit the number of simulators (and corresponding threads) that can be used in the network.

Returns
The maximum number of simulators that can be used in the network.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNetworkEntangledQubitsIds()

template<typename Time = Types::time_type>
virtual std::vector< size_t > Network::INetwork< Time >::GetNetworkEntangledQubitsIds ( size_t hostId) const
pure virtual

Get the qubit ids used for entanglement between hosts for the specified host.

Get the qubit ids used for entanglement between hosts for the specified host.

Parameters
hostIdThe id of the host to get the qubit ids for.
Returns
A vector with the qubit ids.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNumberOfGatesDistributedOrCut()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumberOfGatesDistributedOrCut ( const std::shared_ptr< Circuits::Circuit< Time > > & circuit) const
pure virtual

Get the number of gates that span more than one host.

Get the number of gates that span more than one host for the given circuit.

Parameters
circuitThe circuit to check.
Returns
The number of gates that need distribution or cutting.

◆ GetNumClassicalBits()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumClassicalBits ( ) const
pure virtual

Get the number of classical bits in the network.

Get the number of classical bits in the network, excluding the classical bits used for measurement of entanglement qubits between the hosts.

Returns
The number of classical bits in the network.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNumClassicalBitsForHost()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumClassicalBitsForHost ( size_t hostId) const
pure virtual

Get the number of classical bits in the network for the specified host.

Get the number of classical bits in the network for the specified host, excluding the classical bits used for measurement of entanglement qubits between the hosts.

Parameters
hostIdThe id of the host to get the number of classical bits for.
Returns
The number of classical bits in the network for the specified host.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNumHosts()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumHosts ( ) const
pure virtual

Get the number of hosts in the network.

Get the number of hosts in the network, excluding the controller.

Returns
The number of hosts in the network.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNumNetworkEntangledQubits()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumNetworkEntangledQubits ( ) const
pure virtual

Get the number of qubits used for entanglement between hosts.

Get the number of qubits used for entanglement between hosts in the network.

Returns
The number of qubits used for entanglement between hosts.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNumNetworkEntangledQubitsForHost()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumNetworkEntangledQubitsForHost ( size_t hostId) const
pure virtual

Get the number of qubits used for entanglement between hosts for the specified host.

Get the number of qubits used for entanglement between hosts in the network for the specified host. Usually it's a single qubit.

Parameters
hostIdThe id of the host to get the number of qubits used for entanglement between hosts for.
Returns
The number of qubits used for entanglement between hosts for the specified host.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNumQubits()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumQubits ( ) const
pure virtual

Get the number of qubits in the network.

Get the number of qubits in the network, excluding the qubits used for entanglement between the hosts.

Returns
The number of qubits in the network.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetNumQubitsForHost()

template<typename Time = Types::time_type>
virtual size_t Network::INetwork< Time >::GetNumQubitsForHost ( size_t hostId) const
pure virtual

Get the number of qubits in the network for the specified host.

Get the number of qubits in the network for the specified host, excluding the qubits used for entanglement between the hosts.

Parameters
hostIdThe id of the host to get the number of qubits for.
Returns
The number of qubits in the network for the specified host.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetOptimizeSimulator()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::GetOptimizeSimulator ( ) const
pure virtual

Returns the 'optimize' flag.

Returns the flag set by SetOptimizeSimulator().

Returns
The 'optimize' flag.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ getptr()

template<typename Time = Types::time_type>
std::shared_ptr< INetwork< Time > > Network::INetwork< Time >::getptr ( )
inline

Get a shared pointer to this object.

Returns a shared pointer to this object. The object needs to be already wrapped in a shared pointer.

Returns
A shared pointer to this object.

Definition at line 733 of file Network.h.

◆ GetQubitsIds()

template<typename Time = Types::time_type>
virtual std::vector< size_t > Network::INetwork< Time >::GetQubitsIds ( size_t hostId) const
pure virtual

Get the qubit ids for the specified host.

Get the qubit ids for the specified host.

Parameters
hostIdThe id of the host to get the qubit ids for.
Returns
A vector with the qubit ids.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetScheduler()

template<typename Time = Types::time_type>
virtual std::shared_ptr< Schedulers::IScheduler< Time > > Network::INetwork< Time >::GetScheduler ( ) const
pure virtual

Get the scheduler for the network.

Get the scheduler for the network.

Returns
The scheduler for the network.
See also
Schedulers::IScheduler

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetSimulator()

template<typename Time = Types::time_type>
virtual std::shared_ptr< Simulators::ISimulator > Network::INetwork< Time >::GetSimulator ( ) const
pure virtual

Get the simulator for the network.

Get the simulator for the network.

Returns
The simulator for the network.
See also
Simulators::ISimulator

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetSimulatorsSet()

template<typename Time = Types::time_type>
virtual const SimulatorsSet & Network::INetwork< Time >::GetSimulatorsSet ( ) const
pure virtual

Get the optimizations simulators set.

Get the optimization simulators set. To be used internally, will not be exposed from the library.

Returns
The simulators set.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetState()

template<typename Time = Types::time_type>
virtual Circuits::OperationState & Network::INetwork< Time >::GetState ( )
pure virtual

Get the classical state of the network.

Gets a reference to the classical state of the network.

Returns
The classical state of the network.
See also
Circuits::ClassicalState

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ GetSubroutinesTextCode()

template<typename Time = Types::time_type>
virtual std::vector< std::vector< std::string > > Network::INetwork< Time >::GetSubroutinesTextCode ( ) const
inlinevirtual

Get the text code that is executed on the hosts.

Get the text code that is executed on the hosts, if available. The circuit might be converted to code to be executed (example: netqasm). If that's the case, the text code is returned in an array, each element of the array being the code for a host. Each host might have multiple subroutines, so each element of the array is an array of strings, each string being a subroutine.

Returns
The text code that is executed on the hosts.

Definition at line 902 of file Network.h.

◆ GetType()

template<typename Time = Types::time_type>
virtual NetworkType Network::INetwork< Time >::GetType ( ) const
pure virtual

Get the type of the network.

Get the type of the network.

Returns
The type of the network.
See also
NetworkType

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ IsDistributedOperation()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::IsDistributedOperation ( const std::shared_ptr< Circuits::IOperation< Time > > & op) const
pure virtual

Check if the circuit operation is distributed.

Check if the specified circuit operation is distributed. A distributed operation is an operation that is executed on multiple hosts. This does not include the operations that also operate on the entanglement qubits between hosts.

Parameters
opThe operation to check.
Returns
True if the specified circuit operation is distributed, false otherwise.

◆ IsEntanglementQubitBusy()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::IsEntanglementQubitBusy ( size_t qubitId) const
pure virtual

Check if the specified qubit used for entanglement between hosts is busy.

Check if the specified qubit used for entanglement between hosts is busy.

Parameters
qubitIdThe id of the qubit to check.
Returns
True if the specified qubit used for entanglement between hosts is busy, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ IsEntanglingGate()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::IsEntanglingGate ( const std::shared_ptr< Circuits::IOperation< Time > > & op) const
pure virtual

Checks if a gate is an entangling gate.

An entangling gate is a gate that operates on two qubits that are used for entanglement between hosts.

Parameters
opThe operation to check.
Returns
True if the specified circuit operation is an entangling gate, false otherwise.

◆ IsLocalOperation()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::IsLocalOperation ( const std::shared_ptr< Circuits::IOperation< Time > > & op) const
pure virtual

Check if the circuit operation is local.

Check if the specified circuit operation is local. A local operation is an operation that is executed on a single host. This does not include the operations that also operate on the entanglement qubits between hosts.

Parameters
opThe operation to check.
Returns
True if the specified circuit operation is local, false otherwise.

◆ IsNetworkEntangledQubit()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::IsNetworkEntangledQubit ( size_t qubitId) const
pure virtual

Check if the specified qubit id is for a qubit used for entanglement between hosts.

Check if the specified qubit id is for a qubit used for entanglement between hosts.

Parameters
qubitIdThe id of the qubit to check.
Returns
True if the specified qubit id is for a qubit used for entanglement between hosts, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ MarkEntangledQubitFree()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::MarkEntangledQubitFree ( size_t qubitId)
pure virtual

Mark the specified qubit used for entanglement between hosts as free.

Mark the specified qubit used for entanglement between hosts as free. This is used to mark the qubits as free when they are not used anymore for an entanglement between hosts.

Parameters
qubitIdThe id of the qubit to mark as free.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ MarkEntangledQubitsBusy()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::MarkEntangledQubitsBusy ( size_t qubitId1,
size_t qubitId2 )
pure virtual

Mark the pair of the specified qubits used for entanglement between hosts as busy.

Mark the pair of the specified qubits used for entanglement between hosts as busy. This is used to mark the qubits as busy when they are used for creating an entanglement between hosts.

Parameters
qubitId1The id of the first qubit to mark as busy.
qubitId2The id of the second qubit to mark as busy.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ OperatesWithNetworkEntangledQubit()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::OperatesWithNetworkEntangledQubit ( const std::shared_ptr< Circuits::IOperation< Time > > & op) const
pure virtual

Check if the circuit operation operates on the entanglement qubits between hosts.

Check if the specified circuit operation operates on the entanglement qubits between hosts.

Parameters
opThe operation to check.
Returns
True if the specified circuit operation operates on the entanglement qubits between hosts, false otherwise.

◆ OptimizationSimulatorExists()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::OptimizationSimulatorExists ( Simulators::SimulatorType type,
Simulators::SimulationType kind ) const
pure virtual

Checks if a simulator exists in the optimization set.

Checks if a simulator exists in the optimization set.

Parameters
typeThe type of the simulator to check.
kindThe kind of the simulation to check.
Returns
True if the simulator exists in the optimization set, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ RemoveAllOptimizationSimulatorsAndAdd()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::RemoveAllOptimizationSimulatorsAndAdd ( Simulators::SimulatorType type,
Simulators::SimulationType kind )
pure virtual

Removes all simulators from the simulators optimization set and adds the one specified.

Removes all simulators from the simulators optimization set and adds the one specified.

Parameters
typeThe type of the simulator to add.
kindThe kind of the simulation to add.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ RemoveOptimizationSimulator()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::RemoveOptimizationSimulator ( Simulators::SimulatorType type,
Simulators::SimulationType kind )
pure virtual

Removes a simulator from the simulators optimization set.

Removes a simulator from the simulators optimization set, if it exists.

Parameters
typeThe type of the simulator to remove.
kindThe kind of the simulation to remove.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ RepeatedExecute()

template<typename Time = Types::time_type>
virtual ExecuteResults Network::INetwork< Time >::RepeatedExecute ( const std::shared_ptr< Circuits::Circuit< Time > > & circuit,
size_t shots = 1000 )
pure virtual

Execute the circuit on the network, repeatedly.

Execute the circuit on the network, distributing the operations to the hosts, repeating the execution 'shots' times. The way the circuit is distributed to the hosts depends on the specific interface implementations.

Parameters
circuitThe circuit to execute.
shotsThe number of times to repeat the execution.
Returns
A vector of maps with the results of each circuit execution, where the key is the state as a vector of bools and the value is the number of times it was measured.
See also
Circuits::Circuit

◆ RepeatedExecuteCircuit()

template<typename Time = Types::time_type>
ExecuteResults Network::INetwork< Time >::RepeatedExecuteCircuit ( const Schedulers::ExecuteCircuit< Time > & executeCircuit)
inline

Execute the circuit on the network, repeatedly.

Execute the circuit on the network, distributing the operations to the hosts, repeating the execution 'shots' times. The way the circuit is distributed to the hosts depends on the specific interface implementations.

Parameters
executeCircuitThe circuit to execute, together with the number of shots.
Returns
A vector of maps with the results of each circuit execution, where the key is the state as a vector of bools and the value is the number of times it was measured.
See also
Circuits::Circuit
ExecuteCircuit

Definition at line 184 of file Network.h.

◆ RepeatedExecuteCircuitOnHost()

template<typename Time = Types::time_type>
ExecuteResults Network::INetwork< Time >::RepeatedExecuteCircuitOnHost ( const Schedulers::ExecuteCircuit< Time > & executeCircuit,
size_t hostId )
inline

Execute the circuit on the specified host, repeatedly.

Execute the circuit on the specified host, repeating the execution 'shots' times. The circuit must fit on the host, otherwise an exception is thrown. The circuit will be mapped on the specified host, if its qubits start with indexing from 0 (if already mapped, the qubits won't be altered).

Parameters
executeCircuitThe circuit to execute, together with the number of shots.
hostIdThe id of the host to execute the circuit on.
Returns
A vector of maps with the results of each circuit execution, where the key is the state as a vector of bools and the value is the number of times it was measured.
See also
Circuits::Circuit
ExecuteCircuit

Definition at line 226 of file Network.h.

◆ RepeatedExecuteOnHost()

template<typename Time = Types::time_type>
virtual ExecuteResults Network::INetwork< Time >::RepeatedExecuteOnHost ( const std::shared_ptr< Circuits::Circuit< Time > > & circuit,
size_t hostId,
size_t shots = 1000 )
pure virtual

Execute the circuit on the specified host, repeatedly.

Execute the circuit on the specified host, repeating the execution 'shots' times. The circuit must fit on the host, otherwise an exception is thrown. The circuit will be mapped on the specified host, if its qubits start with indexing from 0 (if already mapped, the qubits won't be altered).

Parameters
circuitThe circuit to execute.
hostIdThe id of the host to execute the circuit on.
shotsThe number of times to repeat the execution.
Returns
A vector of maps with the results of each circuit execution, where the key is the state as a vector of bools and the value is the number of times it was measured.
See also
Circuits::Circuit

◆ SendPacket()

template<typename Time = Types::time_type>
virtual bool Network::INetwork< Time >::SendPacket ( size_t fromHostId,
size_t toHostId,
const std::vector< uint8_t > & packet )
pure virtual

Sends a packet between two hosts.

Sends a packet between the two specified hosts.

Parameters
fromHostIdThe id of the host to send the packet from.
toHostIdThe id of the host to send the packet to.
packetThe packet to send.
Returns
True if the packet was sent successfully, false otherwise.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ SetMaxSimulators()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::SetMaxSimulators ( size_t maxSimulators)
pure virtual

Set the maximum number of simulators that can be used in the network.

Set the maximum number of simulators that can be used in the network. This is used to limit the number of simulators (and corresponding threads) that can be used in the network.

Parameters
maxSimulatorsThe maximum number of simulators that can be used in the network.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.

◆ SetOptimizeSimulator()

template<typename Time = Types::time_type>
virtual void Network::INetwork< Time >::SetOptimizeSimulator ( bool optimize = true)
pure virtual

Allows using an optimized simulator.

If set, allows changing the simulator with an optimized one. States/amplitudes are not available in such a case, disable if you need them.

Parameters
optimizeIf true, the simulator will be optimized if possible.

Implemented in Network::SimpleDisconnectedNetwork< Time, Controller >.


The documentation for this class was generated from the following files: