# Accelerated Randomized Benchmarking¶

## Introduction¶

Randomized benchmarking allows for extracting information about the fidelity
of a quantum operation by exploiting *twirling* errors over an approximate
implementation of the Clifford group [KL+08]. This provides the advantage that the
fidelity can be learned without simulating the dynamics of a quantum system.
Instead, benchmarking admits an analytic form for the survival probability for
an arbitrary input state in terms of the strength \(p\) of an equivalent
depolarizing channel.

**QInfer** supports randomized benchmarking by implementing this survival
probability as a *likelihood function*. This allows for randomized benchmarking
to be used together with Sequential Monte Carlo, such that prior information can
be incorporated and robustness to finite sampling can be obtained [GFC14].

Regardless of the order or interleaving mode, each model instance for randomized
benchmarking yields 0/1 data, with 1 indicating a survival (measuring the same
state after applying a gate sequence as was initially prepared). To use these
models with data batched over many sequences, model instances can be augmented
by `BinomialModel`

.

## Zeroth-Order Model¶

The `RandomizedBenchmarkingModel`

class implements randomized
benchmarking as a **QInfer** model, both in interleaved and non-interleaved
modes. For the non-interleaved mode, there are three model parameters,
\(\vec{x} = (p, A_0, B_0)\), given by [MGE12] as

where \(E_\psi\) is the measurement, \(\rho_\psi\) is the state
preparation, \(\Lambda\) is the average map over timesteps and gateset
elements, \(d\) is the dimension of the system, and where
\(F_\ave\) is the average gate fidelity, taken over the gateset. The
functions `p`

and `F`

convert back and forth between depolarizing
parameters and fidelities.

An experiment parameter vector for this model is simply a specification of
\(m\), the length of the Clifford sequence used for that datum. Since
`RandomizedBenchmarkingModel`

represents 0/1 data, it is common to wrap
this model in a `BinomialModel`

:

```
>>> from qinfer.derived_models import BinomialModel
>>> from qinfer.rb import RandomizedBenchmarkingModel
>>> model = BinomialModel(RandomizedBenchmarkingModel(order=0, interleaved=False))
>>> expparams = np.array([
... (100, 1000) # 1000 shots of sequences with length 100.
... ], dtype=model.expparams_dtype)
```

### Interleaved Mode¶

If one is interested in the fidelity of a single gate, rather than an entire
gateset, then the gate of interest can be interleaved with other gates from
the gateset to isolate its performance. In this mode, models admit an additional
model and experiment parameter, \(\tilde{p}\) and `mode`

, respectively.
The \(\tilde{p}\) model parameter is the depolarizing strength of the
twirl of the interleaved gate, such that the interleaved survival probability is
given by

Model instances for interleaved mode are constructed using the `interleaved=True`

keyword argument:

```
>>> from qinfer.rb import RandomizedBenchmarkingModel
>>> model = RandomizedBenchmarkingModel(interleaved=True)
```