supermarq.qcvv.xeb

Tooling for cross entropy benchmark experiments.

Classes

XEB

Cross-entropy benchmarking (XEB) experiment.

XEBResults

Results from an XEB experiment.

Module Contents

class supermarq.qcvv.xeb.XEB(num_circuits: int, cycle_depths: collections.abc.Iterable[int], interleaved_layer: cirq.Gate | cirq.OP_TREE | None = cirq.CZ, single_qubit_gate_set: collections.abc.Sequence[cirq.Gate] | None = None, *, random_seed: int | numpy.random.Generator | None = None, _samples: list[supermarq.qcvv.base_experiment.Sample] | None = None, **kwargs: str)

Bases: supermarq.qcvv.base_experiment.QCVVExperiment[XEBResults]

Cross-entropy benchmarking (XEB) experiment.

The XEB experiment can be used to estimate the combined fidelity of a repeating cycle of gates. Cycles are made up of randomly selected single qubit gates and a constant layer of interest. This is illustrated as follows:

For each randomly generated circuit, with a given number of cycle, we compare the simulated state probabilities, \(p(x)\) with those achieved by running the circuit on a given target, \(\hat{p}(x)\). The fidelity of a circuit containing \(d\) cycles, \(f_d\) can then be estimated as

\[\sum_{x \in \{0, 1\}^n} p(x) \hat{p}(x) - \frac{1}{2^n} = f_d \left(\sum_{x \in \{0, 1\}^n} p(x)^2 - \frac{1}{2^n}\right)\]

We can therefore fit a linear model to estimate the value of \(f_d\). We the estimate the fidelity of the cycle, \(f_{\mathrm{cycle}}\) as

\[f_d = A(f_{cycle})^d\]

Thus fitting another linear model to \(\log(f_d) \sim d\) provides us with an estimate of the cycle fidelity.

For more details see: https://www.nature.com/articles/s41586-019-1666-5

independent_qubit_groups() list[tuple[cirq.Qid, Ellipsis]]

Get all independent subsets of qubits in this experiment.

Returns:

A list of disjoint tuples of cirq.Qid objects, each of which can be analyzed as an independent XEB experiment.

interleaved_layer: cirq.OP_TREE | None

The layer to interleave.

single_qubit_gate_set: list[cirq.Gate]

The single qubit gates to randomly sample from

class supermarq.qcvv.xeb.XEBResults

Bases: supermarq.qcvv.base_experiment.QCVVResults

Results from an XEB experiment.

plot_results(filename: str | None = None) matplotlib.pyplot.Figure

Plot the experiment data and the corresponding fits.

Parameters:

filename – Optional argument providing a filename to save the plots to. Defaults to None, indicating not to save the plot.

Returns:

A single matplotlib figure containing both the linear fit per cycle depth and the decay with cycle depth.

Raises:

RuntimeError – If there is no data stored.

plot_speckle(filename: str | None = None) matplotlib.pyplot.Figure

Creates the speckle plot of the XEB data. See Fig. S18 of https://arxiv.org/abs/1910.11333 for an explanation of this plot.

Parameters:

filename – Optional argument providing a filename to save the plots to. Defaults to None, indicating not to save the plot.

Returns:

A matplotlib figure with the speckle plot.

Raises:

RuntimeError – If there is no data stored.

property cycle_fidelity_estimate: float

Estimated cycle fidelity.

property cycle_fidelity_estimate_std: float

Standard deviation for the cycle fidelity estimate.