Download

Download this file as Jupyter notebook: cb_example.ipynb.

Example: Running CB

This example explores the Cycle Benchmarking (CB) protocol that allows us to characterize the process infidelity of a dressed cycle (a target cycle preceded by a cycle of random elements of the twirling group).

Choosing Parameters

The make_cb() method generates a circuit collection to perform cycle benchmarking. The first argument required by make_cb() is the cycle to be benchmarked. The second parameter n_random_cycles is also a required parameter, it tells make_cb() how many times to apply the dressed cycle in each random circuit.

The number of circuits for each circuit length, n_circuits, is 30 by default and should be chosen to optimize the tradeoff between desired speed and accuracy of the estimation.

The number of randomly chosen Pauli decay strings used to measure the process fidelity, n_decays, should be chosen to exceed \(min(20, 4^{n_{qubits}} - 1)\). The default value for n_decays is 20 to satisfy this bound. Choosing a value lower than \(min(20, 4^{n_{qubits}} - 1)\) may result in a biased estimate of the fidelity of the dressed cycle.

The twirl parameter specifies which twirling group the random gates which form the pre-compiled dressed cycles are pulled from. By default, make_cb() uses the Pauli group, "P".

The choice of circuit lengths in n_random_cycles depends on the cycle being characterized as well as the selection of twirling group. If the cycle is a Clifford and the twirling group is "P", lengths should be chosen such that applying the cycle to be benchmarked n_random_cycles times will result in an identity operation. In the example below, we benchmark a cycle containing an \(X\) gate and a controlled-\(Z\) gate, both of which apply an identity operation when raised to even powers. We therefore choose cycle lengths 4, 12, 24. While the values of n_random_cycles can be any multiple of 2 for this example, users should be careful to choose a range of values such that the exponential decay is evident in the plot; this will ensure that the fit function gets enough information to accurately estimate the fidelity of the dressed cycle. To validate that this condition has been satisfied, users can plot the data from the CB circuits after running the circuits on a simulator or on hardware to see where the chosen data points fall.

The final parameter is a bool, propagate_correction, which tells make_cb() whether to compile correction gates for the twirling group into neighbouring cycles (propagate_correction=False) or propagate them to the end of the circuit (propagate_correction=True). By default, propagate_correction=False. Warning: propagating correction to the end of the circuit can result in arbitrary two-qubit gates at the end of the circuit! The final circuit can be converted to a user-specified gateset using the Compilation Tools tools.

Benchmarking a Cycle

We begin by initializing a cycle to benchmark:

[2]:
import trueq as tq

cycle = {(0,): tq.Gate.x, (1, 2): tq.Gate.cz}

Generate a circuit collection to run CB on the above cycle with n_circuits=30 random circuits for each circuit length in n_random_cycles=[4, 12, 24] and n_decays=24 randomly chosen Pauli decay strings. For the purpose of demonstrating how to recognize a poor choice of n_random_cycles, we generate a second CB circuit collection with the same parameters, except n_random_cycles=[2, 4, 6]. A good choice of n_random_cycles will result in a lower uncertainty in the fit parameters and therefore a more accurate estimate of the average gate fidelity.

[3]:
circuits = tq.make_cb(cycle, [4, 12, 24], 30, 24)
bad_circuits = tq.make_cb(cycle, [2, 4, 6], 30, 6)

Initialize a simulator with stochastic Pauli noise and run the cycle benchmarking circuits on the simulator to populate their results. Given this error model, we expect the individual Pauli infidelities corresponding to strings with more than two \(Z\) or \(Y\) to be \(0.01 \times 2 \times\) # of \(Z/X\) terms, where the factor of two comes from simulating errors in both the random and interleaved cycles.

[4]:
sim = tq.Simulator().add_stochastic_pauli(px=0.01)
sim.run(circuits)
sim.run(bad_circuits)

Plot the results of the circuits with badly chosen n_random_cycles:

[5]:
bad_circuits.plot.raw()
../../_images/guides_error_diagnostics_cb_example_8_0.png

We can see in the plots above that our choices of n_random_cycles are sampling from the nearly linear portion of the exponential decay. While this is valid, it is not efficient (in terms of the amount of required data) at precisely learning the decay rates. Below, we show the same plots for the better choice n_random_cycles=[4, 12, 24] (ideally, the best place to sample is \(1/e\approx 0.37\)).

[6]:
circuits.plot.raw()
../../_images/guides_error_diagnostics_cb_example_10_0.png

The output parameters of this protocol are displayed below using the fit() function. When the circuits were generated, n_decays=24 random three-qubit Paulis were chosen as representatives, and the rate of decay of each was measured; these decay rates are reported. However, the parameter of interest is the composite parameter e_F, which is an estimate of the process infidelity of the entire cycle.

[7]:
circuits.fit()
[7]:
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".
CB
Cycle Benchmarking
Paulis

(0,) : Gate.x

(1, 2) : Gate.cz

Key:
  • cycles: (Cycle((0,): Gate.x, (1, 2): Gate.cz),)
  • labels: (0, 1, 2)
  • protocol: CB
  • twirl: Paulis on [0, 1, 2]
${e}_{F}$
The probability of an error acting on the specified labels during a dressed cycle of interest.
6.6e-02 (4.8e-03)
0.06617594609099775, 0.004759258381319005
${e}_{III}$
The probability of the subscripted error acting on the specified labels.
9.3e-01 (4.8e-03)
0.9338240539090022, 0.004759258381319005
${p}_{ZZZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.9e-01 (2.0e-02)
0.8929519045640332, 0.019692873616277952
${p}_{ZZY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.8e-01 (1.7e-02)
0.8818557167765103, 0.016945356823875005
${p}_{ZZX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (4.8e-03)
0.9319144371970008, 0.004767664525813597
${p}_{ZZI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (5.8e-03)
0.919092416519045, 0.005759947708934735
${p}_{ZYY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.0e-01 (1.4e-02)
0.90437663351153, 0.01395133066523977
${p}_{ZXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (9.8e-03)
0.912848985214629, 0.009817101996142786
${p}_{ZXX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.7e-03)
0.926175629452402, 0.007749142150058021
${p}_{ZXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (3.2e-03)
0.9430071275297235, 0.0032486741370510086
${p}_{YZX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (5.2e-03)
0.9440941424973269, 0.005229790616063408
${p}_{YZI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (5.7e-03)
0.9292866160941687, 0.005726609723805535
${p}_{YYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (1.1e-02)
0.9165750478890732, 0.01143619252626619
${p}_{YXX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.5e-03)
0.9232568829205011, 0.009521231091058286
${p}_{YIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (1.1e-02)
0.9114078848218505, 0.01056193825415293
${p}_{YIY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (1.2e-02)
0.9147669109102747, 0.012170977648261787
${p}_{YII}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (1.6e-03)
0.9615401526716365, 0.0016437857814963345
${p}_{XZZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (1.1e-02)
0.9159540390690581, 0.011427958285016105
${p}_{XYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (4.8e-03)
0.9388739873797546, 0.0048103345870733035
${p}_{XXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (1.8e-03)
0.9821439958751962, 0.0018478711598800522
${p}_{IZZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (5.4e-03)
0.9219959467654889, 0.005356656487582912
${p}_{IYX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.2e-03)
0.9594043305831741, 0.0032433976617507465
${p}_{IXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (2.1e-03)
0.9576703532138559, 0.002125881046021831
${p}_{IXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (9.1e-04)
0.9807481335442431, 0.000908813497228337
${p}_{IIY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (2.3e-03)
0.9418360188155752, 0.0023262873984681957
${p}_{III}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (1.4e-21)
1.0, 1.3781706614937739e-21
${A}_{ZZZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.9e-01 (1.4e-01)
0.8884473795624924, 0.14443610199816878
${A}_{ZZY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.2e+00 (1.7e-01)
1.1860959152879291, 0.16658913880097387
${A}_{ZZX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (4.7e-02)
1.0189042890402384, 0.047448242725301557
${A}_{ZZI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (4.8e-02)
0.9986727323178399, 0.048251572613719235
${A}_{ZYY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.1e+00 (1.2e-01)
1.0637208442602832, 0.12192197534931883
${A}_{ZXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (8.0e-02)
0.9703352529774981, 0.07952936152107942
${A}_{ZXX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (6.5e-02)
0.9131515265510828, 0.0650345944012136
${A}_{ZXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (2.9e-02)
0.9218068627517786, 0.028729344151464192
${A}_{YZX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01 (4.4e-02)
0.9475871983098493, 0.04373473897315844
${A}_{YZI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (4.6e-02)
0.9425697993999321, 0.046088065088322756
${A}_{YYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.9e-01 (8.8e-02)
0.8875752361418047, 0.08778507532528418
${A}_{YXX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.6e-02)
0.9341580118774219, 0.07603986014945532
${A}_{YIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.1e+00 (9.9e-02)
1.1074327542515965, 0.09916868162388005
${A}_{YIY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (9.6e-02)
0.9282594976905669, 0.09627799398666577
${A}_{YII}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (1.5e-02)
0.989816255020881, 0.0154453779594332
${A}_{XZZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (9.1e-02)
0.9344981102876893, 0.09132748592963215
${A}_{XYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (4.3e-02)
0.9626465859519207, 0.04293411684995568
${A}_{XXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01 (1.7e-02)
0.9537708110658416, 0.017350171463524865
${A}_{IZZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (4.4e-02)
0.9403647049899112, 0.04353336930982629
${A}_{IYX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.1e-02)
0.9567904036561735, 0.03105290683192562
${A}_{IXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (2.1e-02)
0.9899464141217881, 0.021187275911875105
${A}_{IXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (8.9e-03)
0.9772972365962644, 0.00885422290382442
${A}_{IIY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (2.1e-02)
0.9734898591557003, 0.020596232824167678
${A}_{III}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (2.5e-20)
1.0, 2.5358340171485438e-20

The default fit is to the process infidelity of the entire dressed cycle. We can also manually specify qubit labels to query the process infidelity of subsets of qubits, whose errors will be with respect to the context of the entire cycle.

[8]:
circuits.fit(labels=[0, [1, 2], [0, 1, 2]]).plot.compare_twirl("e_F")
../../_images/guides_error_diagnostics_cb_example_14_0.png

Finally, we can compare the individual Pauli infidelities (see CB for definitions), whose average value estimates the process infidelity. See also stochastic calibration SC to select these curves manually.

[9]:
circuits.plot.compare_pauli_infidelities()
../../_images/guides_error_diagnostics_cb_example_16_0.png

Targeting Specific Errors

We can also use cycle benchmarking to estimate the probabilities of specific errors. These errors can be supplied using an optional parameter targeted_errors at generation (see make_cb() for more details) or by updating the keys of existing CB circuits. We demonstrate the latter approach below. Note that if your circuits are already populated with results, the length of each error must correspond to the number of measurements in your circuits.

[10]:
targets = tq.math.Weyls("XII_ZII_IIX_IIZ")
circuits.update_keys(targeted_errors=targets)
circuits.fit()
[10]:
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".
CB
Cycle Benchmarking
Paulis

(0,) : Gate.x

(1, 2) : Gate.cz

Key:
  • cycles: (Cycle((0,): Gate.x, (1, 2): Gate.cz),)
  • labels: (0, 1, 2)
  • protocol: CB
  • twirl: Paulis on [0, 1, 2]
${e}_{F}$
The probability of an error acting on the specified labels during a dressed cycle of interest.
6.6e-02 (4.8e-03)
0.06617594609099775, 0.004759258381319005
${e}_{ZII}$
The probability of the subscripted error acting on the specified labels.
2.9e-05 (4.6e-03)
2.9218196672564645e-05, 0.0046271930069865415
${e}_{XII}$
The probability of the subscripted error acting on the specified labels.
1.7e-02 (4.6e-03)
0.017263139561362384, 0.0045752026877479025
${e}_{IIZ}$
The probability of the subscripted error acting on the specified labels.
6.2e-03 (4.6e-03)
0.006198423936188302, 0.0046231061854554506
${e}_{IIX}$
The probability of the subscripted error acting on the specified labels.
1.6e-02 (4.1e-03)
0.015649383893761415, 0.004069397911023707
${e}_{III}$
The probability of the subscripted error acting on the specified labels.
9.3e-01 (4.8e-03)
0.9338240539090022, 0.004759258381319005
${p}_{ZZZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.9e-01 (2.0e-02)
0.8929519045640332, 0.019692873616277952
${p}_{ZZY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.8e-01 (1.7e-02)
0.8818557167765103, 0.016945356823875005
${p}_{ZZX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (4.8e-03)
0.9319144371970008, 0.004767664525813597
${p}_{ZZI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (5.8e-03)
0.919092416519045, 0.005759947708934735
${p}_{ZYY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.0e-01 (1.4e-02)
0.90437663351153, 0.01395133066523977
${p}_{ZXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (9.8e-03)
0.912848985214629, 0.009817101996142786
${p}_{ZXX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.7e-03)
0.926175629452402, 0.007749142150058021
${p}_{ZXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (3.2e-03)
0.9430071275297235, 0.0032486741370510086
${p}_{YZX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (5.2e-03)
0.9440941424973269, 0.005229790616063408
${p}_{YZI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (5.7e-03)
0.9292866160941687, 0.005726609723805535
${p}_{YYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (1.1e-02)
0.9165750478890732, 0.01143619252626619
${p}_{YXX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.5e-03)
0.9232568829205011, 0.009521231091058286
${p}_{YIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (1.1e-02)
0.9114078848218505, 0.01056193825415293
${p}_{YIY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (1.2e-02)
0.9147669109102747, 0.012170977648261787
${p}_{YII}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (1.6e-03)
0.9615401526716365, 0.0016437857814963345
${p}_{XZZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (1.1e-02)
0.9159540390690581, 0.011427958285016105
${p}_{XYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (4.8e-03)
0.9388739873797546, 0.0048103345870733035
${p}_{XXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (1.8e-03)
0.9821439958751962, 0.0018478711598800522
${p}_{IZZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (5.4e-03)
0.9219959467654889, 0.005356656487582912
${p}_{IYX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.2e-03)
0.9594043305831741, 0.0032433976617507465
${p}_{IXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (2.1e-03)
0.9576703532138559, 0.002125881046021831
${p}_{IXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (9.1e-04)
0.9807481335442431, 0.000908813497228337
${p}_{IIY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (2.3e-03)
0.9418360188155752, 0.0023262873984681957
${p}_{III}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (1.4e-21)
1.0, 1.3781706614937739e-21
${A}_{ZZZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.9e-01 (1.4e-01)
0.8884473795624924, 0.14443610199816878
${A}_{ZZY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.2e+00 (1.7e-01)
1.1860959152879291, 0.16658913880097387
${A}_{ZZX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (4.7e-02)
1.0189042890402384, 0.047448242725301557
${A}_{ZZI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (4.8e-02)
0.9986727323178399, 0.048251572613719235
${A}_{ZYY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.1e+00 (1.2e-01)
1.0637208442602832, 0.12192197534931883
${A}_{ZXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (8.0e-02)
0.9703352529774981, 0.07952936152107942
${A}_{ZXX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (6.5e-02)
0.9131515265510828, 0.0650345944012136
${A}_{ZXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (2.9e-02)
0.9218068627517786, 0.028729344151464192
${A}_{YZX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01 (4.4e-02)
0.9475871983098493, 0.04373473897315844
${A}_{YZI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (4.6e-02)
0.9425697993999321, 0.046088065088322756
${A}_{YYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.9e-01 (8.8e-02)
0.8875752361418047, 0.08778507532528418
${A}_{YXX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.6e-02)
0.9341580118774219, 0.07603986014945532
${A}_{YIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.1e+00 (9.9e-02)
1.1074327542515965, 0.09916868162388005
${A}_{YIY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (9.6e-02)
0.9282594976905669, 0.09627799398666577
${A}_{YII}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (1.5e-02)
0.989816255020881, 0.0154453779594332
${A}_{XZZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (9.1e-02)
0.9344981102876893, 0.09132748592963215
${A}_{XYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (4.3e-02)
0.9626465859519207, 0.04293411684995568
${A}_{XXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01 (1.7e-02)
0.9537708110658416, 0.017350171463524865
${A}_{IZZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (4.4e-02)
0.9403647049899112, 0.04353336930982629
${A}_{IYX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.1e-02)
0.9567904036561735, 0.03105290683192562
${A}_{IXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (2.1e-02)
0.9899464141217881, 0.021187275911875105
${A}_{IXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (8.9e-03)
0.9772972365962644, 0.00885422290382442
${A}_{IIY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (2.1e-02)
0.9734898591557003, 0.020596232824167678
${A}_{III}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (2.5e-20)
1.0, 2.5358340171485438e-20

We can plot the probability of specific errors acting on the qubits during the cycle of interest:

[11]:
circuits.plot.compare_twirl([f"e_{targ}" for targ in targets])
../../_images/guides_error_diagnostics_cb_example_20_0.png

Cycle Benchmarking on Qudits

The make_cb() function natively extends to higher-dimensional qudits without any modifications, however when it comes to our choice of parameters we need to take the qudit dimension into account.

For this example, let’s consider a three-qutrit system and a single cycle consisting of a qutrit \(X\) gate and a controlled-\(Z\) gate (analogous to the qubit example above):

[12]:
tq.settings.set_dim(3)

cycle = {(0,): tq.Gate.x3, (1, 2): tq.Gate.cz3}

# display the cycle in a circuit
tq.Circuit(cycle).draw()
[12]:
0 1 2 Key: Labels: (0,) Name: Gate.x3 Aliases: Gate.x3 Gate.x3pow1 1.00 1.00 1.00 X3 Labels: (1, 2) Name: Gate.cz3 Aliases: Gate.cz3 1.00 1.00 1.00 1.00 -0.50 0.87j -0.50 -0.87j 1.00 -0.50 -0.87j -0.50 0.87j CZ CZ

To create the CB circuits, we need to modify our selected values to n_random_cycles such that all inputs are divisible by \(3\), since the \(CZ3\) gate used in our cycle is of order \(3\) (note that while the \(X3\) gate also has order \(3\), it leaves the Weyl Transfer Matrix invariant up to a phase and hence does not impose a restriction on the sequence length):

[13]:
circuits = tq.make_cb(cycle, [3, 12, 24], 30, 24)

As before, we instantiate a simulator with a stochastic \(X\) error, but since we are now considering qudits, we implement a stochastic Weyl instead of Pauli error by calling the add_stochastic_weyl() method:

[14]:
sim = tq.Simulator().add_stochastic_weyl(W10=0.01)
sim.run(circuits)

Note

Weyl operators are the generalization of the Pauli operators for higher qudit dimensions. Technically, the add_stochastic_weyl() and add_stochastic_pauli() methods for the Simulator are aliases of each other and implement the same operation, however we chose to use the add_stochastic_weyl() just to be explicit. See also Advanced Qudit Framework for more information on the mathematical background of Weyl operators.

When we plot the resulting decays, we expect to see both a real and imaginary component of the fit parameters because the stochastic Weyl error channel for dimensions larger than \(2\) has complex eigenvalues:

[15]:
circuits.plot.raw()
../../_images/guides_error_diagnostics_cb_example_28_0.png

Note that the decay parameters are now expressed in terms of Weyl operators instead of Paulis.

And as before, we can inspect all fitted parameters by calling the fit() method:

[16]:
circuits.fit()
[16]:
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".
CB
Cycle Benchmarking
Paulis

(0,) : Gate.x3

(1, 2) : Gate.cz3

Key:
  • cycles: (Cycle((0,): Gate.x3, (1, 2): Gate.cz3),)
  • labels: (0, 1, 2)
  • protocol: CB
  • twirl: Paulis on [0, 1, 2]
${e}_{F}$
The probability of an error acting on the specified labels during a dressed cycle of interest.
6.1e-02-0.0e+00j (4.8e-03)
(0.06123402681436119-0j), 0.00480296780322327
${e}_{W00W00W00}$
The probability of the subscripted error acting on the specified labels.
9.4e-01+0.0e+00j (4.8e-03)
(0.9387659731856388+0j), 0.00480296780322327
${p}_{W22W21W10}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01+2.4e-02j (7.1e-03)
(0.9262664098677583+0.02368144059893091j), 0.007069161421568948
${p}_{W22W11W10}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01+1.1e-02j (6.7e-03)
(0.9318466526219262+0.01061318458872447j), 0.006747979356552431
${p}_{W22W10W01}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01+1.7e-02j (3.7e-03)
(0.9485249289095792+0.01670196167576147j), 0.003688600677079188
${p}_{W22W00W11}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01+6.4e-03j (8.0e-03)
(0.9167261708266702+0.00639164977849639j), 0.00798887071376452
${p}_{W21W22W22}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.6e-02j (4.4e-03)
(0.9384627369781349-0.01609298181793923j), 0.004368218889732736
${p}_{W21W21W12}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-2.0e-02j (7.6e-03)
(0.9241699457071406-0.020420032952143084j), 0.007609797769441878
${p}_{W21W20W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-1.6e-02j (4.0e-03)
(0.9514962901099259-0.016263474656460088j), 0.004025401659253489
${p}_{W21W10W22}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.7e-02j (6.0e-03)
(0.9389759841643646-0.01662697980706842j), 0.0060190362034616505
${p}_{W20W11W10}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-1.2e-03j (3.2e-03)
(0.9625859293516124-0.0012125518682393288j), 0.003193541444919892
${p}_{W20W01W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01-1.8e-02j (2.6e-03)
(0.9705894830478817-0.01836517183864751j), 0.002573023930311257
${p}_{W20W00W11}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-1.5e-02j (2.8e-03)
(0.9498119511210364-0.014743257083259667j), 0.0028411066323753165
${p}_{W11W21W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-3.7e-02j (7.9e-03)
(0.9218022077995736-0.03722819313575169j), 0.007885109866278054
${p}_{W11W20W20}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-1.2e-02j (6.5e-03)
(0.9337115520957111-0.011828696155581457j), 0.006543274049565687
${p}_{W11W12W20}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-2.4e-02j (7.1e-03)
(0.9262664098677583-0.023681440598930896j), 0.007069161421568949
${p}_{W11W01W22}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-1.0e-02j (9.8e-03)
(0.9218336003682143-0.009994884538452637j), 0.009801692266718474
${p}_{W11W01W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-3.4e-02j (5.3e-03)
(0.9416663527644379-0.03366276139626768j), 0.00530709092607142
${p}_{W10W20W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01+4.4e-04j (2.0e-03)
(0.9765695021945276+0.0004404928676383979j), 0.0019820362402083883
${p}_{W02W21W11}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01+1.5e-02j (6.0e-03)
(0.9325533584249781+0.014523802431797878j), 0.0060499240816663845
${p}_{W02W11W01}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-4.3e-03j (8.3e-03)
(0.9246534036774678-0.004287097907563041j), 0.008330565505576532
${p}_{W02W10W10}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01+1.6e-02j (6.0e-03)
(0.9383034782525834+0.015610849079329454j), 0.006026441057698415
${p}_{W02W10W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01+2.0e-02j (4.0e-03)
(0.953241408718295+0.019778693544715523j), 0.003960738582458869
${p}_{W02W02W11}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-6.9e-03j (9.4e-03)
(0.9247237885826316-0.006854548645455579j), 0.009412406408130796
${p}_{W01W21W02}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-2.8e-02j (7.6e-03)
(0.9223604022848295-0.02814340080563131j), 0.007577828800581922
${p}_{W01W20W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-2.0e-02j (4.0e-03)
(0.9532414087182949-0.019778693544715523j), 0.003960738582458863
${A}_{W22W21W10}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01-7.6e-02j (5.4e-02)
(0.9727504453227899-0.07612391166005213j), 0.05395930791601791
${A}_{W22W11W10}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01+1.5e-02j (5.1e-02)
(0.9812633203894978+0.014538284815466733j), 0.051041452380665514
${A}_{W22W10W01}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-1.3e-02j (3.2e-02)
(0.9486516637048745-0.013349469278200743j), 0.03203774000379252
${A}_{W22W00W11}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00-6.6e-02j (6.5e-02)
(1.002564274076188-0.06577417548973462j), 0.06533048186972115
${A}_{W21W22W22}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-1.3e-02j (3.7e-02)
(0.9325120824273604-0.012724176174494482j), 0.0366038509221785
${A}_{W21W21W12}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01-2.1e-03j (5.8e-02)
(0.9914606370201019-0.002139282896459645j), 0.058404030403901776
${A}_{W21W20W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-2.2e-02j (3.2e-02)
(0.9486143282669761-0.02177581987279163j), 0.03153659231799764
${A}_{W21W10W22}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-2.2e-02j (4.3e-02)
(0.9251157250387364-0.021570481802270152j), 0.04294040343872053
${A}_{W20W11W10}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.7e-02j (2.7e-02)
(0.9370606509181825-0.017299784358132793j), 0.02682492899862336
${A}_{W20W01W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01-1.1e-02j (2.3e-02)
(0.966499190635809-0.011210998274082132j), 0.022831586215932537
${A}_{W20W00W11}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01-1.8e-02j (2.3e-02)
(0.9800568689612125-0.017760734077014784j), 0.022943778279239158
${A}_{W11W21W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01+2.9e-02j (5.9e-02)
(0.9647474397044117+0.029273875144702814j), 0.05863194019266811
${A}_{W11W20W20}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-6.4e-02j (4.9e-02)
(0.9384336851697381-0.0635162744680535j), 0.04921935776498322
${A}_{W11W12W20}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01+7.6e-02j (5.4e-02)
(0.9727504453227899+0.07612391166005208j), 0.05395930791601792
${A}_{W11W01W22}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01+7.2e-02j (7.4e-02)
(0.9687288337415363+0.07156334618433154j), 0.07386989354911785
${A}_{W11W01W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-6.7e-03j (4.2e-02)
(0.9639522369940309-0.006669804795594717j), 0.042399809428643284
${A}_{W10W20W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00-1.7e-02j (1.7e-02)
(1.0010285446418776-0.01742422779758479j), 0.017483456620455813
${A}_{W02W21W11}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01-1.9e-02j (4.8e-02)
(0.9831310585648895-0.01895865068920585j), 0.047849350694507034
${A}_{W02W11W01}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.6e-02j (6.1e-02)
(0.9436027084209307-0.015897148879914984j), 0.0606856627768631
${A}_{W02W10W10}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.9e-01+1.2e-02j (4.6e-02)
(0.8933068977269881+0.011936959356021279j), 0.04627328658170457
${A}_{W02W10W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-1.9e-03j (3.1e-02)
(0.9515045579078553-0.0019143467696580917j), 0.03128862598677454
${A}_{W02W02W11}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01+6.8e-02j (6.5e-02)
(0.9126930618814401+0.0681838576710363j), 0.06487881094342089
${A}_{W01W21W02}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-3.6e-02j (5.8e-02)
(0.9625562272705065-0.035547522849936806j), 0.05823376405987328
${A}_{W01W20W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01+1.9e-03j (3.1e-02)
(0.9515045579078563+0.0019143467696584354j), 0.031288625986774565

Download

Download this file as Jupyter notebook: cb_example.ipynb.