Download

Download this file as Jupyter notebook: xrb_example.ipynb.

Example: Running 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 the built-in 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.

[2]:
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()
../../_images/guides_error_diagnostics_xrb_example_2_0.png

Print the fit summary:

[3]:
circuits.fit()
[3]:
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.
4.0e-02 (1.1e-03)
0.03990025500391248, 0.0011058178057678086
${u}$
The unitarity of the noise, that is, the average decrease in the purity of an initial state.
9.2e-01 (2.3e-03)
0.9165776216976557, 0.0022649501724369193
${A}$
SPAM parameter of the exponential decay $Au^m$.
9.9e-01 (1.1e-02)
0.9885852821916654, 0.010555966236052493

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.

For example, to generate XRB circuits to simultaneously characterize a single qubit [0], a pair of qubits [1, 2], and another single qubit [3] with \(9 \times 30\) random circuits for each circuit depth [2, 4, 16], we can write:

[4]:
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()
../../_images/guides_error_diagnostics_xrb_example_6_0.png

Print the fit summary:

[5]:
circuits.fit()
[5]:
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.0e-02 (9.0e-04)
0.0203082570737263, 0.0009048684270170223
3.9e-02 (1.1e-03)
0.039314760625807965, 0.0010875155266826333
2.0e-02 (6.9e-04)
0.020037912355612697, 0.0006851398783018274
${u}$
The unitarity of the noise, that is, the average decrease in the purity of an initial state.
9.5e-01 (2.4e-03)
0.94639454821056, 0.0023639790036886995
9.2e-01 (2.2e-03)
0.9177772044282119, 0.0022288215766917466
9.5e-01 (1.8e-03)
0.9471009242937946, 0.0017904296145842139
${A}$
SPAM parameter of the exponential decay $Au^m$.
9.8e-01 (1.1e-02)
0.9790897171301861, 0.010620234938750386
9.8e-01 (1.0e-02)
0.9757693535064662, 0.010021807785937807
9.8e-01 (1.1e-02)
0.9757546475848845, 0.010910167346511351

Simultaneous XRB on Qudits

The make_xrb() function can be used for qudits of higher dimension in exactly the same way as for qubits. For example, consider the same simultaneous characterization configuration as in the example above but with qutrits instead of qubits:

[6]:
# set the global dimension to 3 for qutrits
tq.settings.set_dim(3)

# create circuits for the simultaneous characterization of
# qutrit 1, the qutrit pair (1, 2) and qutrit 3:
circuits = tq.make_xrb([[0], [1, 2], [3]], [2, 4, 16], 30)

# display a sample circuit
circuits[0].draw()
[6]:
0 1 2 3 Key: twirl: Cliffords on [0, (1, 2), 3] protocol: XRB seq_label: 4545 n_random_cycles: 2 measurement_basis: W22W11W02W10 1 Labels: (0,) Name: Gate 0.58 0.58 -0.29 0.50j -0.29 -0.50j 0.58 -0.29 -0.50j -0.29 -0.50j -0.29 0.50j -0.29 0.50j Labels: (1, 2) Name: Gate 0.33 0.33 -0.17 0.29j -0.17 -0.29j -0.17 -0.29j 0.33 -0.17 0.29j -0.17 0.29j -0.17 -0.29j -0.17 -0.29j 0.33 -0.17 -0.29j -0.17 0.29j -0.17 -0.29j -0.17 0.29j 0.33 -0.17 0.29j 0.33 -0.17 0.29j 0.33 0.33 0.33 -0.17 -0.29j -0.17 -0.29j -0.17 -0.29j -0.17 0.29j -0.17 0.29j 0.33 -0.17 0.29j 0.33 0.33 -0.17 0.29j 0.33 0.33 -0.17 0.29j 0.33 -0.17 -0.29j -0.17 0.29j -0.17 0.29j -0.17 -0.29j -0.17 0.29j -0.17 0.29j -0.17 -0.29j -0.17 0.29j -0.17 0.29j -0.17 0.29j -0.17 0.29j -0.17 -0.29j -0.17 0.29j -0.17 0.29j -0.17 -0.29j -0.17 0.29j -0.17 0.29j -0.17 -0.29j 0.33 -0.17 -0.29j -0.17 -0.29j -0.17 0.29j 0.33 0.33 -0.17 -0.29j -0.17 0.29j -0.17 0.29j -0.17 -0.29j -0.17 -0.29j 0.33 0.33 0.33 -0.17 0.29j -0.17 0.29j -0.17 0.29j -0.17 -0.29j -0.17 0.29j -0.17 -0.29j -0.17 0.29j -0.17 -0.29j 0.33 -0.17 -0.29j 0.33 -0.17 0.29j 0.33 Labels: (3,) Name: Gate 0.58 0.58 -0.29 0.50j -0.29 0.50j -0.29 -0.50j -0.29 0.50j -0.29 0.50j 0.58 0.58 2 Labels: (0,) Name: Gate -0.29 0.50j 0.58 -0.29 0.50j 0.58 0.58 -0.29 -0.50j -0.29 0.50j -0.29 -0.50j -0.29 -0.50j Labels: (1, 2) Name: Gate -0.29 -0.50j -0.29 0.50j -0.29 -0.50j 0.58 0.58 -0.29 -0.50j 0.58 -0.29 0.50j -0.29 0.50j -0.29 -0.50j -0.29 -0.50j -0.29 0.50j -0.29 0.50j -0.29 -0.50j -0.29 -0.50j -0.29 -0.50j -0.29 0.50j -0.29 -0.50j 0.58 -0.29 0.50j -0.29 0.50j 0.58 -0.29 -0.50j 0.58 -0.29 -0.50j -0.29 -0.50j -0.29 0.50j Labels: (3,) Name: Gate -0.50 0.87j 1.00 1.00 3 Labels: (0,) Name: Meas M Labels: (1,) Name: Meas M Labels: (2,) Name: Meas M Labels: (3,) Name: Meas M

We again initialize a noisy simulator with overrotation errors and stochastic Pauli noise. The add_overrotation() method works natively for qudits of higher dimension. To implement the stochastic noise, we use a probabilistic sum of Weyl operators, analogous to the stochastic Pauli channel used for qubits. We add this noise to our simulator using the add_stochastic_weyl() method. For this example, we add a small qutrit \(X\) and \(X^2\) error:

[7]:
sim = tq.Simulator().add_stochastic_pauli(W10=0.02, W20=0.01).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()
../../_images/guides_error_diagnostics_xrb_example_12_0.png

Display the fit parameter:

[8]:
circuits.fit()
[8]:
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.
3.0e-02 (1.1e-03)
0.03021550925779637, 0.001069931682867676
5.6e-02 (1.1e-03)
0.056054340152158155, 0.0011410003133364263
2.9e-02 (1.2e-03)
0.028981929910023907, 0.001161767086571425
${u}$
The unitarity of the noise, that is, the average decrease in the purity of an initial state.
9.3e-01 (2.3e-03)
0.9330422032946297, 0.00233460709244725
8.9e-01 (2.2e-03)
0.8896713263548973, 0.002181010644659368
9.4e-01 (2.5e-03)
0.9357356039964194, 0.0025382178771674382
${A}$
SPAM parameter of the exponential decay $Au^m$.
9.7e-01 (1.0e-02)
0.9740117035676729, 0.010392734139136262
1.0e+00 (1.1e-02)
0.9950412763563655, 0.011365358987451807
9.8e-01 (1.2e-02)
0.9811322820286514, 0.012023409703851884

Download

Download this file as Jupyter notebook: xrb_example.ipynb.