qml.pauli.PauliGroupingStrategy

class PauliGroupingStrategy(observables, grouping_type='qwc', graph_colourer='rlf')[source]

Bases: object

Class for partitioning a list of Pauli words according to some binary symmetric relation.

Partitions are defined by the binary symmetric relation of interest, e.g., all Pauli words in a partition being mutually commuting. The partitioning is accomplished by formulating the list of Pauli words as a graph where nodes represent Pauli words and edges between nodes denotes that the two corresponding Pauli words satisfy the symmetric binary relation.

Obtaining the fewest number of partitions such that all Pauli terms within a partition mutually satisfy the binary relation can then be accomplished by finding a partition of the graph nodes such that each partition is a fully connected subgraph (a “clique”). The problem of finding the optimal partitioning, i.e., the fewest number of cliques, is the minimum clique cover (MCC) problem. The solution of MCC may be found by graph colouring on the complementary graph. Both MCC and graph colouring are NP-Hard, so heuristic graph colouring algorithms are employed to find approximate solutions in polynomial time.

Parameters
  • observables (list[Observable]) – a list of Pauli words to be partitioned according to a grouping strategy

  • grouping_type (str) – the binary relation used to define partitions of the Pauli words, can be 'qwc' (qubit-wise commuting), 'commuting', or 'anticommuting'.

  • graph_colourer (str) – the heuristic algorithm to employ for graph colouring, can be 'lf' (Largest First) or 'rlf' (Recursive Largest First)

Raises

ValueError – if arguments specified for grouping_type or graph_colourer are not recognized

binary_repr([n_qubits, wire_map])

Converts the list of Pauli words to a binary matrix.

colour_pauli_graph()

Runs the graph colouring heuristic algorithm to obtain the partitioned Pauli words.

complement_adj_matrix_for_operator()

Constructs the adjacency matrix for the complement of the Pauli graph.

binary_repr(n_qubits=None, wire_map=None)[source]

Converts the list of Pauli words to a binary matrix.

Parameters
  • n_qubits (int) – number of qubits to specify dimension of binary vector representation

  • wire_map (dict) – dictionary containing all wire labels used in the Pauli word as keys, and unique integer labels as their values

Returns

a column matrix of the Pauli words in binary vector representation

Return type

array[int]

colour_pauli_graph()[source]

Runs the graph colouring heuristic algorithm to obtain the partitioned Pauli words.

Returns

a list of the obtained groupings. Each grouping is itself a list of Pauli word Observable instances

Return type

list[list[Observable]]

complement_adj_matrix_for_operator()[source]

Constructs the adjacency matrix for the complement of the Pauli graph.

The adjacency matrix for an undirected graph of N vertices is an N by N symmetric binary matrix, where matrix elements of 1 denote an edge, and matrix elements of 0 denote no edge.

Returns

the square and symmetric adjacency matrix

Return type

array[int]