Note
Click here to download the full example code
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 [2, 4, 16]
circuits = tq.make_xrb([[0, 1]], [2, 4, 16], 30)
# initialize a noisy simulator with stochastic Pauli and overrotation
sim = tq.Simulator().add_stochastic_pauli(px=0.02).add_overrotation(0.04)
# 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()
![XRB on [0, 1]](../../_images/sphx_glr_xrb_001.png)
# print the fit summary
circuits.fit()
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 [0],
# a pair of qubits [1, 2], and another single qubit [3] with 9 * 30 random circuits
# for each circuit depth [2, 4, 16]
circuits = tq.make_xrb([[0], [1, 2], [3]], [2, 4, 16], 30)
# initialize a noisy simulator with stochastic Pauli and overrotation
sim = tq.Simulator().add_stochastic_pauli(px=0.02).add_overrotation(0.04)
# 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()
![XRB on [0], XRB on [1, 2], XRB on [3]](../../_images/sphx_glr_xrb_002.png)
# print the fit summary
circuits.fit()
Total running time of the script: ( 0 minutes 2.722 seconds)