Characteristic Matrices#
- qnetti.qubit_shannon_entropies(probs_vec)[source]#
Given a probability distribution of qubit measurement data, evaluates the shannon entropy on each qubit subsystem.
Let \(X\) denote a random variable on the qubit measurement results. The Shannon entropy is defined as
\[H(X) = - \sum_i P(x_i) \log_2(P(x_i))\]where \(P(x_i)\) denotes the probability of the \(i^{th}\) outcome.
- Parameters:
probs_vec (np.array) – A probability distribution that contains positive elements that sum to one.
- Returns:
The \(i^{th}\) list element corresponds to the Shannon entropy of the \(i^{th}\) qubit.
- Return type:
list[float]
- qnetti.qubit_mutual_infos(probs_vec)[source]#
Given a probability distribution of qubit measurement data, evaluates the mutual information between each pair of qubits.
Let \(X\) and \(Y\) be random variables representing the measurement outcomes of two qubits in the network. The mutual information is then expressed as
\[I(X;Y) = H(X) + H(Y) - H(XY)\]where \(H(\cdot)\) denotes the Shannon entropy.
- Parameters:
probs_vec (np.array) – A probability distribution that contains positive elements that sum to one.
- Returns:
The mutual information between qubit pairs
(q1, q2)
whereq1 + 1 <= q2
. The qubit pairs are ordered as(0,1), (0,2), ..., (1,2), (1,3), ...
.- Return type:
list[float]
- qnetti.qubit_measured_mutual_infos_fn(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={})[source]#
Constructs a function that evaluates the mutual information for all qubit pairs in the network where each qubit pair is measured using unique settings.
The mutual information is computed for each qubit pair using
qnetti.qubit_mutual_infos()
on the two-qubit probability distribution output from the qubit measurements.- Parameters:
prep_node (qnetvo.PrepareNode) – a network node that prepares the quantum state to evaluate
meas_wires (list[int]) – The qubit wires to measure in the network. If
None
all wires are measured.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
- Returns:
A function
qubit_measured_mutual_infos(settings)
where settings has length 6 times the number of distinct qubit pairs.- Return type:
function
- qnetti.shannon_entropy_cost_fn(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={})[source]#
Constructs a cost function from the sum of Shannon entropoes on each qubit.
Let \(X_i\) denote the random variable associated with the \(i^{th}\) qubit’s measurement result. The Shannon entropy cost function is then
\[Cost = \sum_{i} H(X_i)\]where the Shannon entropy \(H(X_i)\) is evaluated in
qnetti.qubit_shannon_entropies()
.- Parameters:
prep_node (qnetvo.PrepareNode) – a network node that prepares the quantum state to evaluate
meas_wires (list[int]) – The qubit wires to measure in the network. If
None
all wires are measured.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
- Returns:
A function
shannon_entropy_cost(settings)
that evaluates the specified cost function.- Return type:
qml.QNode
- qnetti.mutual_info_cost_fn(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={})[source]#
Constructs a cost function from the sum of mutual information across all unique pairs of qubits in the network.
Let \(X_i\) denote the random variable associated with the \(i^{th}\) qubit’s measurement result. The mutual information cost function is then
\[Cost = -\sum_{i < j} I(X_i ; X_j)\]where the mutual information \(I(X_i ; X_j)\) is evaluated in
qnetti.qubit_mutual_infos()
- Parameters:
prep_node (qnetvo.PrepareNode) – a network node that prepares the quantum state to evaluate
meas_wires (list[int]) – The qubit wires to measure in the network. If
None
all wires are measured.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
- Returns:
A function
mutual_info_cost(settings)
that evaluates the specified cost function.- Return type:
qml.QNode
- qnetti.measured_mutual_info_cost_fn(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={})[source]#
Constructs a cost function for maximizing the measured mutual information across all qubit pairs in the network.
In the context of quantum networks, the measured mutual information quantifies the correlation between measurement statistics of a pair of qubit measurement devices that each perform a local measurement.
Formally, let \(X\) and \(Y\) be random variables representing measurement outcomes of two measurement devices in the network, where projective measurements \(\{\Pi^X\}\) and \(\{\Pi^Y\}\) are performed on respective devices. Then, the measured mutual information seeks to find the measurement bases that maximize the mutual information between \(X\) and \(Y\):
\[I_m (X:Y) = \max_{\{\Pi^X\}, \{\Pi^X\}} H(X) + H(Y) - H(XY)\]where \(H(\cdot)\) denotes the Shannon entropy. The returned cost function is then
\[Cost = -\sum_{i<j} I_m(X_i:Y_j).\]- Parameters:
prep_node (qnetvo.PrepareNode) – a network node that prepares the quantum state to evaluate
meas_wires (list[int]) – The qubit wires to measure in the network. If
None
all wires are measured.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
- Returns:
A function
measured_mutual_info_cost(settings)
that evaluates the specified cost function.- Return type:
Function
- qnetti.qubit_characteristic_matrix_fn(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={}, use_measured_mutual_info=False)[source]#
Given the preparation nodes, return a function that evaluates the characteristic matrix from two sets of settings, one for the Shannon entropies representing the diagonal elements, the other for the mutual information represeting the off-diagonal elements
- Parameters:
prep_node (qnetvo.PrepareNode) – a network node that prepares the quantum state to evaluate
meas_wires (list[int]) – The qubit wires to measure in the network. If
None
all wires are measured.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
use_measured_mutual_info (bool) – If
True
the measured mutual information is evaluated with respect to all qubit pairs. DefaultFalse
.
- Returns:
A function
characteristic_matrix(vn_entropy_settings, mutual_info_settings)
where the parameters are the qubit measurement settings for the von Neumann entropy and mutual information.- Return type:
function
- qnetti.optimize_vn_entropy(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={}, **opt_kwargs)[source]#
Optimizes the network’s arbitrary qubit measurements to minimize the
qnetti.shannon_entropy_cost_fn()
. The minimum Shannon entropy corresponds to the von Neumann entropy.The optimization is performed using the
qnetti.optimize()
method where- Parameters:
prep_node (qnetvo.PrepareNode) – A network node that prepares the quantum state to evaluate.
meas_wires (list[int]) – The wires to measure when evaluating the covariance matrix. If
meas_wires
are not specified, all wires in the prepare node are considered. This can be used to ignore ancillary qubits.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
step_size (float) – The step to take in the direction of steepest descent. Default
step_size=0.1
.num_steps (int) – The number of iterations of gradient descent to perform. Default
num_steps=20
.verbose (bool) – If
True
, the iteration step and cost will be printed every 5 iterations.
- Returns:
The dictionary returned from
qnetti.optimize()
- Return type:
dict
- qnetti.optimize_mutual_info(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={}, **opt_kwargs)[source]#
Optimizes the network’s arbitrary qubit measurements to minimize the
qnetti.mutual_info_cost_fn()
. See theqnetti.optimize()
method for details regarding the gradient optimization.- Parameters:
prep_node (qnetvo.PrepareNode) – A network node that prepares the quantum state to evaluate.
meas_wires (list[int]) – The wires to measure when evaluating the covariance matrix. If
meas_wires
are not specified, all wires in the prepare node are considered. This can be used to ignore ancillary qubits.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
step_size (float) – The step to take in the direction of steepest descent. Default
step_size=0.1
.num_steps (int) – The number of iterations of gradient descent to perform. Default
num_steps=20
.verbose (bool) – If
True
, the iteration step and cost will be printed every 5 iterations.
- Returns:
The dictionary returned from
qnetti.optimize()
- Return type:
dict
- qnetti.optimize_measured_mutual_info(prep_node, meas_wires=None, dev_kwargs={}, qnode_kwargs={}, **opt_kwargs)[source]#
Optimizes the network’s arbitrary qubit measurements to minimize the
qnetti.measured_mutual_info_cost_fn()
. See theqnetti.optimize()
method for details regarding the gradient optimization.- Parameters:
prep_node (qnetvo.PrepareNode) – A network node that prepares the quantum state to evaluate.
meas_wires (list[int]) – The wires to measure when evaluating the covariance matrix. If
meas_wires
are not specified, all wires in the prepare node are considered. This can be used to ignore ancillary qubits.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
step_size (float) – The step to take in the direction of steepest descent. Default
step_size=0.1
.num_steps (int) – The number of iterations of gradient descent to perform. Default
num_steps=20
.verbose (bool) – If
True
, the iteration step and cost will be printed every 5 iterations.
- Returns:
The dictionary returned from
qnetti.optimize()
- Return type:
dict
- qnetti.optimize_characteristic_matrix(prep_node, use_measured_mutual_info=False, meas_wires=None, dev_kwargs={}, qnode_kwargs={}, mi_opt_kwargs={}, vn_opt_kwargs={})[source]#
Obtains the qubit characteristic matrix for a given multi-qubit state preparation.
Mathematically, the qubit characteristic matrix is a real-valued matrix \(Q \in \mathbb{R}^{n \times n}\), \(n\) being the number of qubits in a network. On the diagonal, \(Q\) stores the von Neumann entropy of the respective qubit, i.e. for any \(i \in [n]\), \(Q_{ii} = S(q_i)\). On the other hand, off-diagonal entries stores the measured mutual information between qubits: \(Q_{ij} = I_m(q_i;q_j)\) for \(i \neq j\). For further details, see https://arxiv.org/abs/2212.07987.
This function uses the
qnetti.optimize_vn_entropy()
andqnetti.optimize_mutual_info()
methods to find the optimal measurement settinggs for inferring the network’s topology.- Parameters:
prep_node (qnetvo.PrepareNode) – A network node that prepares the quantum state to evaluate.
meas_wires (list[int]) – The wires to measure when evaluating the covariance matrix. If
meas_wires
are not specified, all wires in the prepare node are considered. This can be used to ignore ancillary qubits.dev_kwargs (dict) – Keyword arguments passed to the PennyLane device constructor.
qnode_kwargs (dict) – Keyword arguments passed to the PennyLane qnode constructor.
step_size (float) – The step to take in the direction of steepest descent. Default
step_size=0.1
.num_steps (int) – The number of iterations of gradient descent to perform. Default
num_steps=20
.verbose (bool) – If
True
, the iteration step and cost will be printed every 5 iterations.use_measured_mutual_info (bool) – If
True
the measured mutual information is evaluated with respect to all qubit pairs. DefaultFalse
.
- Returns:
A tuple containing the characteristic matrix, the mutual information optimizaation resullts, and the von Neumann entropy optimization results.
- Return type:
tuple[matrix, dict, dict]
- qnetti.characteristic_matrix_decoder(characteristic_matrix, tol=1e-05)[source]#
Decode the qubit characteristic matrix and partition qubits into their respective preparation nodes.
If two qubits come from the same preparation node, they are correlated and have identical rows in the qubit characteristic matrix.
- Parameters:
characteristic_matrix (matrix array) – the qubit characteristic matrix of an unknown network
tol – tolerance for distinguishing non-zero elements
- Type:
float
- Returns:
a list of lists representing qubits that shares entanglement sources
- Return type:
list[list[int]]