group_settings

forest.benchmarking.observable_estimation.group_settings(obs_expt: forest.benchmarking.observable_estimation.ObservablesExperiment, method: str = 'greedy') → forest.benchmarking.observable_estimation.ObservablesExperiment

Group settings that are diagonal in a shared tensor product basis (TPB) to minimize number of QPU runs.

Background:

Given some PauliTerm operator, the ‘natural’ tensor product basis to diagonalize this term is the one which diagonalizes each Pauli operator in the product term-by-term.

For example, X(1) * Z(0) would be diagonal in the ‘natural’ tensor product basis

\[\{ (|0> + |1>)/ \sqrt{2}, (|0> - |1>)/ \sqrt{2} \} * \{ |0>, |1> \}\]

whereas, Z(1) * X(0) would be diagonal in the ‘natural’ TPB

\[\{ |0>, |1> \} * \{ (|0> + |1>)/ \sqrt{2}, (|0> - |1>)/ \sqrt{2} \}\]

The two operators commute but are not diagonal in each others ‘natural’ TPB (in fact, they are anti-diagonal in each others ‘natural’ TPB). This function tests whether two operators given as PauliTerms are both diagonal in each others ‘natural’ TPB. Note that for the given example of X(1) * Z(0) and Z(1) * X(0), we can construct the following basis which simultaneously diagonalizes both operators:

|a> =  |0> |+> + |1> |->
|b> =  |0> |+> - |1> |->
|c> =  |0> |-> + |1> |+>
|d> = -|0> |-> + |1> |+>

In this basis, X Z looks like diag(1, -1, 1, -1), and Z X looks like diag(1, 1, -1, -1). Notice however that this basis cannot be constructed with single-qubit operations, as each of the basis vectors are entangled states.

Methods:

The “greedy” method will keep a running set of ‘buckets’ into which grouped ExperimentSettings will be placed. Each new ExperimentSetting considered is assigned to the first applicable bucket and a new bucket is created if there are no applicable buckets.

The “clique-removal” method maps the term grouping problem onto Max Clique graph problem. This method constructs a NetworkX graph where an edge exists between two settings that share an nTPB and then uses networkx’s algorithm for clique removal. This method can give you marginally better groupings in certain circumstances, but constructing the graph is pretty slow so “greedy” is the default.

Parameters:
  • obs_expt – an ObservablesExperiment
  • method – method used for grouping; the allowed methods are one of [‘greedy’, ‘clique-removal’]
Returns:

an ObservablesExperiment with all the same settings, just grouped according to shared TPBs.