# Extended Randomized Benchmarking (XRB)¶

This example illustrates how to generate extended randomized benchmarking (XRB) circuits and use them to estimate the probability of a stochastic error acting on the specified system(s) during a random gate. While this example uses a simulator to execute the circuits, the same procedure can be followed for hardware applications.

## Isolated XRB¶

This section illustrates how to generate XRB circuits to characterize a pair of qubits in isolation. Here, we are performing two-qubit XRB which learns the stochastic infidelity over the two-qubit Clifford gateset.

import trueq as tq

# generate XRB circuits to characterize a pair of qubits [0, 1]
# with 9 * 30 random circuits for each circuit depth [4, 32, 64]
circuits = tq.make_xrb([[0, 1]], [4, 32, 64], 30)

# initialize a noisy simulator with stochastic Pauli and overrotation

# run the circuits on the simulator to populate their results
sim.run(circuits, n_shots=1000)

# plot the exponential decay of the purities
circuits.plot.raw() # print the fit summary
circuits.fit()

True-Q formatting will not be loaded without trusting this notebook or rerunning the affected cells. Notebooks can be marked as trusted by clicking "File -> Trust Notebook".
 XRB Extended Randomized Benchmarking Cliffords (0, 1) Key: labels: (0, 1) protocol: XRB twirl: Cliffords on [(0, 1)] ${e}_{S}$ The probability of a stochastic error acting on the specified systems during a random gate. 3.6e-02 (4.0e-04) 0.036364378419704524, 0.00039508678002372194 ${u}$ The unitarity of the noise, that is, the average decrease in the purity of an initial state. 9.2e-01 (8.1e-04) 0.9238331852570052, 0.0008122020156721423 ${A}$ SPAM parameter of the exponential decay $Au^m$. 9.4e-01 (1.0e-02) 0.9378539598443021, 0.01037865923913497

## Simultaneous XRB¶

This section demonstrates how to generate XRB circuits that characterize the amount of stochastic noise while gates are applied simultaneously on a device.

# generate XRB circuits to simultaneously characterize a single qubit ,
# a pair of qubits [1, 2], and another single qubit  with 9 * 30 random circuits
# for each circuit depth [4, 32, 64]
circuits = tq.make_xrb([, [1, 2], ], [4, 32, 64], 30)

# initialize a noisy simulator with stochastic Pauli and overrotation

# run the circuits on the simulator to populate their results
sim.run(circuits, n_shots=1000)

# plot the exponential decay of the purities
circuits.plot.raw() # print the fit summary
circuits.fit()

True-Q formatting will not be loaded without trusting this notebook or rerunning the affected cells. Notebooks can be marked as trusted by clicking "File -> Trust Notebook".
 XRB Extended Randomized Benchmarking Cliffords (0,) Key: labels: (0,) protocol: XRB twirl: Cliffords on [0, (1, 2), 3] Cliffords (1, 2) Key: labels: (1, 2) protocol: XRB twirl: Cliffords on [0, (1, 2), 3] Cliffords (3,) Key: labels: (3,) protocol: XRB twirl: Cliffords on [0, (1, 2), 3] ${e}_{S}$ The probability of a stochastic error acting on the specified systems during a random gate. 2.1e-02 (2.6e-04) 0.020520268219155313, 0.0002591315580962583 3.8e-02 (4.0e-04) 0.0382739863343613, 0.00039559637461903996 2.0e-02 (2.7e-04) 0.02015664056516575, 0.00027493473230415336 ${u}$ The unitarity of the noise, that is, the average decrease in the purity of an initial state. 9.5e-01 (6.8e-04) 0.9458407266259672, 0.0006768376240535344 9.2e-01 (8.1e-04) 0.919911387051947, 0.0008116380253502889 9.5e-01 (7.2e-04) 0.9467906787047224, 0.0007183812579365826 ${A}$ SPAM parameter of the exponential decay $Au^m$. 1.0e+00 (1.4e-02) 1.001937306280546, 0.013918762195231985 9.7e-01 (1.2e-02) 0.9683653150714785, 0.012096171863906583 9.7e-01 (1.4e-02) 0.9730659849757097, 0.014467323518881347

Total running time of the script: ( 0 minutes 8.783 seconds)

Gallery generated by Sphinx-Gallery