qml.grouping¶
This subpackage defines functions and classes for Pauliword partitioning functionality used in measurement optimization.
A Pauli word is defined as \(P_J = \prod_{i=1}^{N}\sigma_i^{(J)}\), where
\(\sigma_i^{(J)}\) is one of the Pauli operators (PauliX
,
PauliY
, PauliZ
) or identity
(Identity
) acting on the \(i^{th}\) qubit.
Pauli words can be used for expressing a qubit Hamiltonian
.
A qubit Hamiltonian has the form \(H_{q} = \sum_{J} C_J P_J\) where
\(C_{J}\) are numerical coefficients, and \(P_J\) are Pauli words.
A list of Pauli words can be partitioned according to certain grouping
strategies. As an example, the group_observables()
function partitions
a list of observables (Pauli operations and tensor products thereof) into
groupings according to a binary relation (e.g., qubitwise commuting):
>>> observables = [qml.PauliY(0), qml.PauliX(0) @ qml.PauliX(1), qml.PauliZ(1)]
>>> obs_groupings = group_observables(observables)
>>> obs_groupings
[[Tensor(PauliX(wires=[0]), PauliX(wires=[1]))],
[PauliY(wires=[0]), PauliZ(wires=[1])]]
The \(C_{J}\) coefficients for each \(P_J\) Pauli word making up a Hamiltonian can also be specified along with further options, such as the Pauliword grouping method (e.g., qubitwise commuting) and the underlying graphcolouring algorithm (e.g., recursive largest first) used for creating the groups of observables:
>>> obs = [qml.PauliY(0), qml.PauliX(0) @ qml.PauliX(1), qml.PauliZ(1)]
>>> coeffs = [1.43, 4.21, 0.97]
>>> obs_groupings, coeffs_groupings = group_observables(obs, coeffs, 'qwc', 'rlf')
>>> obs_groupings
[[Tensor(PauliX(wires=[0]), PauliX(wires=[1]))],
[PauliY(wires=[0]), PauliZ(wires=[1])]]
>>> coeffs_groupings
[[4.21], [1.43, 0.97]]
pennylane.grouping Package¶
This subpackage defines functions and classes for Pauliword partitioning functionality used in measurement optimization.
Functions¶

Performs a check if two Pauli words have the same 

Converts a binary vector of even dimension to an Observable instance. 

Transforms the Pauli word to diagonal form in the computational basis. 

Diagonalizes a list of qubitwise commutative groupings of Pauli strings. 

Diagonalizes a list of mutually qubitwise commutative Pauli words. 

Partitions a list of observables (Pauli operations and tensor products thereof) into groupings according to a binary relation (qubitwise commuting, fullycommuting, or anticommuting). 

Checks if an observable instance is a Pauli word. 

Checks if two Pauli words in the binary vector representation are qubitwise commutative. 

Converts a list of Pauli words to the binary vector representation and yields a row matrix of the binary vectors. 

Partitions then diagonalizes a list of Pauli words, facilitating simultaneous measurement of all observables within a partition. 

Converts a Pauli word to the binary vector representation. 

Obtains the adjacency matrix for the complementary graph of the qubitwise commutativity graph for a given set of observables in the binary representation. 

Performs circuit implementation of diagonalizing unitary for a Pauli word. 
Classes¶

Class for partitioning a list of Pauli words according to some binary symmetric relation. 
pennylane.grouping.graph_colouring Module¶
A module for heuristic algorithms for colouring Pauli graphs.
A Pauli graph is a graph where vertices represent Pauli words and edges denote if a specified symmetric binary relation (e.g., commutation) is satisfied for the corresponding Pauli words. The graphcolouring problem is to assign a colour to each vertex such that no vertices of the same colour are connected, using the fewest number of colours (lowest “chromatic number”) as possible.
Functions¶

Performs graphcolouring using the Largest Degree First heuristic. 

Performs graphcolouring using the Recursive Largest Degree First heuristic. 
Contents
Downloads