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.
3.8e-02 (8.4e-04)
0.038083735786155204, 0.0008365264727778669
${u}$
The unitarity of the noise, that is, the average decrease in the purity of an initial state.
9.2e-01 (1.7e-03)
0.920301759316394, 0.0017166259618356695
${A}$
SPAM parameter of the exponential decay $Au^m$.
9.7e-01 (9.8e-03)
0.9728249296391774, 0.009838532065530503

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.
1.9e-02 (8.3e-04)
0.01918115551282784, 0.000831512342391367
3.8e-02 (9.1e-04)
0.038465533682625175, 0.0009149457170894447
1.9e-02 (7.6e-04)
0.01876995061237252, 0.0007634297208202652
${u}$
The unitarity of the noise, that is, the average decrease in the purity of an initial state.
9.5e-01 (2.2e-03)
0.9493408076015356, 0.0021748345995763266
9.2e-01 (1.9e-03)
0.9195184319106547, 0.001876803929154063
9.5e-01 (2.0e-03)
0.9504165464283278, 0.001997600487105204
${A}$
SPAM parameter of the exponential decay $Au^m$.
9.7e-01 (1.1e-02)
0.9711489373348242, 0.011174577197816863
9.7e-01 (1.0e-02)
0.9721515613435953, 0.010163614018285434
9.5e-01 (9.7e-03)
0.9489192563492524, 0.009654199584510302

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: 2675 n_random_cycles: 2 measurement_basis: W01W11W01W01 1 Labels: (0,) Name: Gate 0.58 -0.29 -0.50j -0.29 0.50j 0.58 0.58 0.58 0.58 -0.29 0.50j -0.29 -0.50j Labels: (1, 2) Name: Gate 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.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.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.17 -0.29j -0.17 -0.29j 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.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.33 -0.17 0.29j -0.17 0.29j 0.33 -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.17 -0.29j 0.33 -0.17 0.29j 0.33 -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.33 -0.17 0.29j -0.17 0.29j Labels: (3,) Name: Gate 0.58 -0.29 -0.50j -0.29 0.50j 0.58 0.58 0.58 -0.29 0.50j -0.29 -0.50j 0.58 2 Labels: (0,) Name: Gate 0.58 -0.29 -0.50j -0.29 0.50j -0.29 0.50j -0.29 -0.50j 0.58 0.58 0.58 0.58 Labels: (1, 2) Name: Gate 0.29 0.17j 0.29 0.17j 0.29 0.17j -0.33j -0.29 0.17j 0.29 0.17j -0.29 0.17j -0.33j 0.29 0.17j -0.33j 0.29 0.17j -0.29 0.17j -0.29 0.17j -0.29 0.17j -0.29 0.17j 0.29 0.17j -0.33j -0.29 0.17j -0.29 0.17j 0.29 0.17j -0.33j 0.29 0.17j -0.29 0.17j -0.33j -0.33j -0.33j -0.33j -0.33j 0.29 0.17j -0.29 0.17j 0.29 0.17j 0.29 0.17j 0.29 0.17j -0.29 0.17j 0.29 0.17j -0.33j 0.29 0.17j -0.33j -0.29 0.17j -0.29 0.17j -0.33j 0.29 0.17j -0.33j -0.33j -0.33j -0.29 0.17j -0.29 0.17j -0.29 0.17j -0.33j -0.29 0.17j 0.29 0.17j 0.29 0.17j -0.29 0.17j -0.33j -0.33j -0.29 0.17j 0.29 0.17j -0.33j 0.29 0.17j -0.29 0.17j -0.33j -0.33j -0.33j -0.33j -0.33j -0.33j -0.33j -0.29 0.17j 0.29 0.17j -0.33j 0.29 0.17j -0.29 0.17j -0.33j 0.29 0.17j -0.29 0.17j -0.33j -0.33j -0.33j -0.33j -0.29 0.17j 0.29 0.17j Labels: (3,) Name: Gate 0.58 0.58 0.58 0.58 -0.29 0.50j -0.29 -0.50j -0.29 0.50j 0.58 -0.29 -0.50j 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 (7.1e-04)
0.0301691228358425, 0.000714187974726974
5.5e-02 (1.0e-03)
0.05533361077947674, 0.001041072337763493
3.1e-02 (7.9e-04)
0.030651440231025617, 0.0007906500002407934
${u}$
The unitarity of the noise, that is, the average decrease in the purity of an initial state.
9.3e-01 (1.6e-03)
0.933143421588624, 0.0015584434874764976
8.9e-01 (2.0e-03)
0.8910495192594778, 0.0019915187436206263
9.3e-01 (1.7e-03)
0.932091209116958, 0.0017244347377831928
${A}$
SPAM parameter of the exponential decay $Au^m$.
9.7e-01 (1.0e-02)
0.97060112340084, 0.0101226341792284
9.8e-01 (9.8e-03)
0.984314560724523, 0.009750943149098227
9.8e-01 (1.0e-02)
0.9840909426533007, 0.010103409796961178

Download

Download this file as Jupyter notebook: xrb_example.ipynb.