Network Nodes¶
A quantum network is constructed from a collection of quantum devices serving as nodes in the network. Each network node operates on its local set of qubits. Each node’s operation can be conditioned upon both classical inputs and the measurement results of other nodes in the network.
- class qnetvo.NetworkNode(num_in=1, num_out=1, wires=[], cc_wires_in=[], cc_wires_out=[], ansatz_fn=None, num_settings=0)[source]¶
A quantum network node.
- Parameters:
num_in (int) – The number of discrete classical inputs that the node accepts.
num_out (int) – The number of classical outputs for the node.
wires (list[int]) – The wires on which the node operates.
cc_wires_in (list[int]) – The classical communication wires input to the node.
cc_wires_out (list[int]) – The classical communication wires to output measurement results on.
ansatz_fn (function) – A PennyLane quantum circuit function called either as
circuit(settings, wires)
, or ascircuit(settings, wires, cc_wires)
wheresettings
is an array[float] of lengthnum_settings
andcc_wires
contains the measurement results received from upstream nodes.num_settings (int) – The number of settings parameterizing the
ansatz_fn
circuit.
- Returns:
An instance of the
NetworkNode
class.
Calling a Network Node’s Ansatz Function:
Given an instantiated network node,
node = NetworkNode(*args)
, its ansatz quantum circuit functtion can be called asnode(settings, cc_wires)
or, ifnode.cc_wires_in==[]
, the node can be called asnode(settings)
provided thatcc_wires=[]
.Attributes:
All inputs are stored as class attributes under the same name, e.g., the
num_in
argument is stored asnode.num_in
.
Network nodes are categorized by their function:
Prepare Node: Initializes a quantum state on the local qubits.
Processing Node: Applies an operation to its local qubits.
Noise Node: Applies noise to the local qubits.
Measure Node: Measures local qubits and outputs a classical value.
CC Sender Node: Measures local qubits and sends the result to classical communication (CC) receiver nodes.
CC Receiver Node: Applies an operation to its local qubits conditioned upon receieved classical data.
Prepare Nodes¶
- class qnetvo.PrepareNode(num_in=1, wires=[], ansatz_fn=None, num_settings=0)[source]¶
A network node that initializes a state on its local qubit wires where the preparation can be conditioned on a classical input or upstream measurement results.
- Parameters:
num_in (int) – The number of discrete classical inputs that the node accepts.
wires (list[int]) – The wires on which the node operates.
ansatz_fn (function) –
A PennyLane quantum circuit function that takes the following form:
def prepare_ansatz(settings, wires): # initalize quantum state from |0...0> qml.ArbitraryStatePreparation(settings[0:6], wires=wires[0:2])
where
settings
is an array[float] of lengthnum_settings
.num_settings (int) – The number of settings parameterizing the
ansatz_fn
circuit.
All attributes are inherited from the
qnetvo.NetworkNode
class.- Returns:
An instantiated
PrepareNode
class.
Processing Nodes¶
- class qnetvo.ProcessingNode(num_in=1, wires=[], ansatz_fn=None, num_settings=0)[source]¶
A network node that operates upon its local qubit wires where the operation can be conditioned upon a classical input or upstream measurement results.
- Parameters:
num_in (int) – The number of discrete classical inputs that the node accepts.
wires (list[int]) – The wires on which the node operates.
ansatz_fn (function) –
A PennyLane quantum circuit function that takes the following form:
def processing_ansatz(settings, wires): # apply processing operation qml.ArbitraryUnitary(settings[0:16], wires=wires[0:2])
where
settings
is an array[float] of lengthnum_settings
.num_settings (int) – The number of settings parameterizing the
ansatz_fn
circuit.
All attributes are inherited from the
qnetvo.NetworkNode
class.- Returns:
An instantiated
ProcessingNode
class.
Measure Nodes¶
- class qnetvo.MeasureNode(num_in=1, num_out=1, wires=[], ansatz_fn=None, num_settings=0)[source]¶
A network node that measures its local qubit wires where the measurement can be conditioned on a classical input or upstream measurement results.
- Parameters:
num_in (int) – The number of discrete classical inputs that the node accepts.
num_out (int) – The number of classical outputs for the node.
wires (list[int]) – The wires on which the node operates.
ansatz_fn (function) –
A PennyLane quantum circuit function that takes the following form:
def measure_ansatz(settings, wires): # rotate measurement basis qml.Rot(*settings[0:3], wires=wires[0])
where
settings
is an array[float] of lengthnum_settings
. Note that the measurement ansatz does not apply a measurement operation. Measurement operations are specified later whenqnetvo.NetworkAnsatz
class is used to construct qnodes and cost functions.num_settings (int) – The number of settings parameterizing the
ansatz_fn
circuit.
All attributes are inherited from the
qnetvo.NetworkNode
class. In addition, the number of classical outputs are specified.- Returns:
An instantiated
MeasureNode
class.
Classical Communication Nodes¶
- class qnetvo.CCSenderNode(num_in=1, wires=[], cc_wires_out=[], ansatz_fn=None, num_settings=0)[source]¶
A network node that measures one or more of its local qubits and sends the measurement result(s) to one or more downstream
qnetvo.CCReceiverNode
instances.- Parameters:
num_in (int) – The number of discrete classical inputs that the node accepts.
wires (list[int]) – The wires on which the node operates.
cc_wires_out (list[int]) – The classical communication wires to output measurement results on.
ansatz_fn (function) –
A PennyLane quantum circuit function that takes the following form:
def cc_sender_ansatz(settings, wires): # apply quantum circuit operations qml.Rot(*settings[0:3], wires=wires[0]) # measure qubit to obtain classical communication bit cc_bit_out = qml.measure(wires[0]) # output list of measurement results return [cc_bit_out]
where
settings
is an array[float] of lengthnum_settings
. Note that for each wire specified incc_wires_out
, there should be a correspondingcc_bit_out
result obtained using qml.measure.num_settings (int) – The number of settings parameterizing the
ansatz_fn
circuit.
All attributes are inherited from the
qnetvo.NetworkNode
class.- Returns:
An instantiated
CCSenderNode
class.
- class qnetvo.CCReceiverNode(num_in=1, wires=[], cc_wires_in=[], ansatz_fn=None, num_settings=0)[source]¶
A network node that receives classical communication from an upstream
qnetvo.CCSenderNode
.- Parameters:
num_in (int) – The number of discrete classical inputs that the node accepts.
wires (list[int]) – The wires on which the node operates.
cc_wires_in (list[int]) – The classical communication wires input to the node.
ansatz_fn (function) –
A PennyLane quantum circuit function that takes the following form:
def cc_receive_ansatz(settings, wires, cc_wires): # apply quantum operations conditioned on classical communication qml.cond(cc_wires[0], qml.Rot)(*settings[0:3], wires=wires[0]) qml.cond(cc_wires[1], qml.Rot)(*settings[3:6], wires=wires[0])
where
settings
is an array[float] of lengthnum_settings
andcc_wires
contains the measurement results received from upstream nodes.num_settings (int) – The number of settings parameterizing the
ansatz_fn
circuit.
All attributes are inherited from the
qnetvo.NetworkNode
class.Note that the classical inputs specified by
num_in
are distinct from the classical communication inputs passed throughcc_wires
. That is, the classical inputsnum_in
are known before the network simulation is run whereas the classical communication incc_wires
are determined during the simulation.- Returns:
An instantiated
CCReceiverNode
class.
Noise Nodes¶
- class qnetvo.NoiseNode(wires=[], ansatz_fn=None)[source]¶
A network node that applies noise to its local qubit wires.
- Parameters:
wires (list[int) – The wires on which the node operates.
ansatz_fn (function) –
A PennyLane quantum circuit function <https://docs.pennylane.ai/en/stable/introduction/circuits.html> that takes the following form:
def noise_ansatz(settings, wires): # apply noise operation qml.Depolarizing(0.5, wires=wires[0]) qml.AmplitudeDamping(0.5, wires=wires[1])
where
settings=[]
is unused because noise is considered to be static.
We model noise to be independent from classical inputs and upstream measurement results. Therefore, only the
wires
andansatz_fn
attributes can be set. All attributes are inherited from theqnetvo.NetworkNode
class.- Returns:
An instantiated
NoiseNode
class.