QNodes¶
A qnetvo.NetworkAnsatz()
is executed on a PennyLane QNode object.
The output of the QNode execution can either be the probility of obtaining
each output or the expectation of an observable.
The considered cost function dictates which type of QNode measurement is applied.
Probability QNodes¶
- qnetvo.joint_probs_qnode(network_ansatz, **qnode_kwargs)[source]¶
Constructs a qnode that computes the joint probabilities in the computational basis across all measurement wires.
- Parameters:
network_ansatz (NetworkAnsatz) – A
NetworkAnsatz
class specifying the quantum network simulation.- Returns:
A qnode called as
qnode(settings)
for evaluating the joint probabilities of the network ansatz.- Return type:
pennylane.QNode
Density Matrix QNodes¶
- qnetvo.density_matrix_qnode(network_ansatz, wires=None, **qnode_kwargs)[source]¶
Constructs a qnode that computes the density matrix in the computational basis across specified wires, or across all wires if no specific wires are provided.
- Parameters:
network_ansatz (NetworkAnsatz) – A
NetworkAnsatz
class specifying the quantum network simulation.wires (list[int] or None) – The wires on which the node operates. If None, the density matrix will be computed across all wires in the network ansatz.
- Returns:
A qnode called as
qnode(settings)
for evaluating the (reduced) density matrix of the network ansatz.- Return type:
pennylane.QNode
- Raises:
ValueError – If the specified wires are not a subset of the wires in the network ansatz.
Parity Observable QNodes¶
- qnetvo.local_parity_expval_qnode(network_ansatz, **qnode_kwargs)[source]¶
Constructs a qnode that computes expectation values for the local parity observable at each measurement node.
- Parameters:
network_ansatz (NetworkAnsatz) – A
NetworkAnsatz
class specifying the quantum network simulation.- Returns:
A qnode that performs a local parity measurement at measurement nodes. The qnode is called as
qnode(settings)
.- Return type:
qml.QNode
- qnetvo.global_parity_expval_qnode(network_ansatz, **qnode_kwargs)[source]¶
Constructs a qnode that computes expectation values for the local parity observable at each measurement node.
- Parameters:
network_ansatz (NetworkAnsatz) – A
NetworkAnsatz
class specifying the quantum network simulation.- Returns:
A qnode the performs a global parity measurement and is called as
qnode(settings)
.- Return type:
qml.QNode
Helper Functions for Parity Observables¶
- qnetvo.parity_observable(wires)[source]¶
Constructs the parity observable for the provided
wires
in the computational basis.- Parameters:
wires (qml.wires.Wires) – A list of
MeasureNode
classes for which to construct the observables.- Returns:
A parity
qml.Observable
across all wires.
- qnetvo.local_parity_observables(measure_nodes)[source]¶
Constructs a list of dichotomic observables for each measurement node. The observables are constructed as products of
qml.PauliZ
qubit operators and therefore, a \(+1\) outcome corresponds to an Even parity bit string whereas a \(-1\) outcome corresponds to an Odd parity bit string.- Parameters:
measure_nodes (list[ MeasureNode ]) – A list of
MeasureNode
classes for which to construct the observables.
- qnetvo.parity_vector(n_qubits)[source]¶
Constructs a vector with elements \(\pm 1\) describing the parity of an \(n\)-bit string measured from \(n\)-qubits. The (+) and (-) elements indicate even and odd parity respectively and are placed in the index corresponding to the bit string’s value.
- Parameters:
n_qubits (int) – The number of qubits for which to consider the parity vector.
- Raises:
ValueError – If
n_qubits < 1
.