optimize_measurements(observables, coefficients=None, grouping='qwc', colouring_method='rlf')[source]¶
Partitions then diagonalizes a list of Pauli words, facilitating simultaneous measurement of all observables within a partition.
The input list of observables are partitioned into mutually qubit-wise commuting (QWC) or mutually commuting partitions by approximately solving minimum clique cover on a graph where each observable represents a vertex. The unitaries which diagonalize the partitions are then found. See arXiv:1907.03358 and arXiv:1907.09386 for technical details of the QWC and fully-commuting measurement-partitioning approaches respectively.
observables (list[Observable]) – a list of Pauli words (Pauli operation instances and Tensor instances thereof)
coefficients (list[float]) – a list of float coefficients, for instance the weights of the Pauli words comprising a Hamiltonian
grouping (str) – the binary symmetric relation to use for operator partitioning
colouring_method (str) – the graph-colouring heuristic to use in obtaining the operator partitions
list[callable]: a list of the post-rotation templates, one for each partition
list[list[Observable]]: A list of the obtained groupings. Each grouping is itself a list of Pauli words diagonal in the measurement basis.
list[list[float]]: A list of coefficient groupings. Each coefficient grouping is itself a list of the partitions corresponding coefficients. Only output if coefficients are specified.
- Return type
>>> obs = [qml.PauliY(0), qml.PauliX(0) @ qml.PauliX(1), qml.PauliZ(1)] >>> coeffs = [1.43, 4.21, 0.97] >>> rotations, groupings, grouped_coeffs = optimize_measurements(obs, coeffs, 'qwc', 'rlf') >>> print(rotations) [[RY(-1.5707963267948966, wires=), RY(-1.5707963267948966, wires=)], [RX(1.5707963267948966, wires=)]] >>> print(groupings) [[PauliZ(wires=) @ PauliZ(wires=)], [PauliZ(wires=), PauliZ(wires=)]] >>> print(grouped_coeffs) [[4.21], [1.43, 0.97]]
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry
- Quantum Datasets
- QNode returns