supermarq.qcvv.xeb

Tooling for cross entropy benchmark experiments.

Classes

XEB

Cross-entropy benchmarking (XEB) experiment.

XEBResults

Results from an XEB experiment.

XEBSample

The samples used in XEB experiments.

Module Contents

class supermarq.qcvv.xeb.XEB(single_qubit_gate_set: list[cirq.Gate] | None = None, two_qubit_gate: cirq.Gate | None = cirq.CZ, *, random_seed: int | numpy.random.Generator | None = None)

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

Cross-entropy benchmarking (XEB) experiment.

The XEB experiment can be used to estimate the combined fidelity of a repeating cycle of gates. In our case, where we restrict ourselves to two qubits, we use cycles made up of two randomly selected single qubit phased XZ gates and a constant two qubit gate. 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

analyze_results(plot_results: bool = True) XEBResults

Analyse the results and calculate the estimated circuit fidelity.

Parameters:

plot_results (optional) – Whether to generate the data plots. Defaults to True.

Returns:

The final results from the experiment.

plot_results() None

Plot the experiment data and the corresponding fits.

property circuit_fidelities: pandas.DataFrame

The circuit fidelity calculations from the most recently run experiment.

Raises:

RuntimeError – If no data is available.

property samples: collections.abc.Sequence[XEBSample]

The samples generated during the experiment.

Raises:

RuntimeError – If no samples are available.

single_qubit_gate_set: list[cirq.Gate]

The single qubit gates to randomly sample from

two_qubit_gate: cirq.Gate | None

The two qubit gate to use for interleaving.

class supermarq.qcvv.xeb.XEBResults

Bases: supermarq.qcvv.base_experiment.BenchmarkingResults

Results from an XEB experiment.

cycle_fidelity_estimate: float

Estimated cycle fidelity.

cycle_fidelity_estimate_std: float

Standard deviation for the cycle fidelity estimate.

experiment_name = 'XEB'
class supermarq.qcvv.xeb.XEBSample

Bases: supermarq.qcvv.base_experiment.Sample

The samples used in XEB experiments.

sum_target_cross_sample_probs() float

Compute the dot product between the sample and target probabilities

Raises:

RuntimeError – If either the target or sample probabilities have not yet been initialised.

Returns:

The dot product between the sample and target probabilities.

Return type:

float

sum_target_probs_square() float

Compute the sum of the squared target probabilities.

Raises:

RuntimeError – If no target probabilities have been initialised.

Returns:

The sum of squared target probabilities.

Return type:

float

sample_probabilities: dict[str, float] | None = None

The sample probabilities obtained from the chosen target

target_probabilities: dict[str, float] | None = None

The target probabilities obtained through a noiseless simulator