group_observables(observables, coefficients=None, grouping_type='qwc', method='rlf')[source]¶
Partitions a list of observables (Pauli operations and tensor products thereof) into groupings according to a binary relation (qubit-wise commuting, fully-commuting, or anticommuting).
Partitions are found by 1) mapping the list of observables to a graph where vertices represent observables and edges encode the binary relation, then 2) solving minimum clique cover for the graph using graph-colouring heuristic algorithms.
observables (list[Observable]) – a list of Pauli word
Observableinstances (Pauli operation instances and
coefficients (tensor_like) – A tensor or list of coefficients. If not specified, output
partitioned_coeffsis not returned.
grouping_type (str) – The type of binary relation between Pauli words. Can be
method (str) – the graph coloring heuristic to use in solving minimum clique cover, which can be
'lf'(Largest First) or
'rlf'(Recursive Largest First)
list[list[Observable]]: A list of the obtained groupings. Each grouping is itself a list of Pauli word
list[tensor_like]: A list of coefficient groupings. Each coefficient grouping is itself a tensor or list of the grouping’s corresponding coefficients. This is only returned if coefficients are specified.
- Return type
IndexError – if the input list of coefficients is not of the same length as the input list of Pauli words
>>> 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, 'anticommuting', 'lf') >>> obs_groupings [[PauliZ(wires=), PauliX(wires=) @ PauliX(wires=)], [PauliY(wires=)]] >>> coeffs_groupings [[0.97, 4.21], [1.43]]
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry
- Quantum Datasets
- QNode returns