# 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)


Plot the results of the circuits with badly chosen n_random_cycles:

[5]:

bad_circuits.plot.raw()


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()


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. 5.9e-02 (4.9e-03) 0.05932469334167423, 0.0049020264565428915 ${e}_{III}$ The probability of the subscripted error acting on the specified labels. 9.4e-01 (4.9e-03) 0.9406753066583258, 0.0049020264565428915 ${p}_{ZZZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 8.8e-01 (2.1e-02) 0.8778171284215314, 0.021167748750971577 ${p}_{ZZX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (4.5e-03) 0.948673287227443, 0.004529707086937106 ${p}_{ZXZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (4.5e-03) 0.946629922951542, 0.004471446732253854 ${p}_{ZXY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01 (8.3e-03) 0.9178570830918114, 0.008336742277313566 ${p}_{ZXX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.0e-01 (1.3e-02) 0.904939725756637, 0.013122659139390978 ${p}_{ZXI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (3.3e-03) 0.9397087562888965, 0.003314684577019876 ${p}_{ZIZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01 (4.6e-03) 0.9342970814555008, 0.0046203488039331 ${p}_{ZII}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (1.5e-03) 0.960389515641083, 0.0015197434290932814 ${p}_{YZY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.1e-01 (9.2e-03) 0.9063934016373328, 0.009192217119963684 ${p}_{YYY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01 (9.3e-03) 0.9209062078857914, 0.00932005659179143 ${p}_{YYI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.0e-01 (1.4e-02) 0.8961444332376696, 0.01419033604586991 ${p}_{YIY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.1e-01 (9.3e-03) 0.9052343851230582, 0.009265692306516552 ${p}_{YIX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (6.0e-03) 0.939884541345959, 0.005995197001144808 ${p}_{XYI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (5.9e-03) 0.9390470133438547, 0.0058590704791723165 ${p}_{XXY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.3e-03) 0.9606246349084654, 0.0033432430873495426 ${p}_{XXX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.7e-03) 0.960379054148023, 0.0036964560753722825 ${p}_{XIZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (2.6e-03) 0.9607354126233814, 0.0026187505210687697 ${p}_{XIY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (6.5e-03) 0.9397244401206025, 0.006468302725636417 ${p}_{IZX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (1.4e-03) 0.9791986276596473, 0.0014217595890347462 ${p}_{IYI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (3.9e-03) 0.9398063147364136, 0.0038780382219142694 ${p}_{IXI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (7.9e-04) 0.9809284415442054, 0.0007946364201698768 ${p}_{IIY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (3.0e-03) 0.9377843291628644, 0.0030429570134895487 ${p}_{IIX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (9.2e-04) 0.9791036214881103, 0.0009228156135803154 ${p}_{III}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00 (1.6e-21) 1.0, 1.5591363342197772e-21 ${A}_{ZZZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.1e+00 (2.0e-01) 1.123755162168166, 0.19721062425294683 ${A}_{ZZX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 8.8e-01 (4.3e-02) 0.879175501322384, 0.042526762323276734 ${A}_{ZXZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 8.9e-01 (3.8e-02) 0.8939374389930288, 0.03796975471647425 ${A}_{ZXY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (7.3e-02) 0.9867333044569134, 0.0725540542212821 ${A}_{ZXX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.1e+00 (1.2e-01) 1.1211505526070644, 0.12037496954441856 ${A}_{ZXI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00 (2.9e-02) 0.995357398892783, 0.028659678077831385 ${A}_{ZIZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.1e-01 (3.8e-02) 0.911480709234707, 0.03793803164902658 ${A}_{ZII}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (1.4e-02) 0.9911877888374598, 0.014156047374888082 ${A}_{YZY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (8.0e-02) 0.9770218209548845, 0.08044338839751888 ${A}_{YYY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (7.4e-02) 0.9457859327219312, 0.07379640105239452 ${A}_{YYI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (1.2e-01) 0.9842097121888828, 0.11841557737002678 ${A}_{YIY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (7.5e-02) 0.9458143996668499, 0.07454735792375403 ${A}_{YIX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (5.0e-02) 0.9557389837373932, 0.05011545938936463 ${A}_{XYI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (5.1e-02) 0.9498783537394647, 0.05107101441805456 ${A}_{XXY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.1e-02) 0.9587306970237476, 0.031489865176374705 ${A}_{XXX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (3.2e-02) 0.9702429480507555, 0.03200094119878441 ${A}_{XIZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (2.8e-02) 0.9676837719622322, 0.027880870010087957 ${A}_{XIY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (5.4e-02) 0.9853884063882858, 0.05421689273322557 ${A}_{IZX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (1.5e-02) 0.9697988320518097, 0.014699520487465824 ${A}_{IYI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.4e-02) 0.9551016324161047, 0.03425255381732674 ${A}_{IXI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (8.7e-03) 0.9729016940157551, 0.008738778552891121 ${A}_{IIY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (2.6e-02) 0.9934322327132123, 0.026419578640157246 ${A}_{IIX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (9.3e-03) 0.9831057114833658, 0.009334806851247338 ${A}_{III}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00 (2.9e-20) 1.0, 2.86881085496439e-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")


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()


## 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. 5.9e-02 (4.9e-03) 0.05932469334167423, 0.0049020264565428915 ${e}_{ZII}$ The probability of the subscripted error acting on the specified labels. 6.7e-03 (4.7e-03) 0.00665824647506752, 0.004699526294192171 ${e}_{XII}$ The probability of the subscripted error acting on the specified labels. 1.9e-02 (3.8e-03) 0.019292602782711665, 0.0037829864908672925 ${e}_{IIZ}$ The probability of the subscripted error acting on the specified labels. 2.4e-03 (5.2e-03) 0.0023559983498593895, 0.005166295871923522 ${e}_{IIX}$ The probability of the subscripted error acting on the specified labels. 1.2e-02 (4.6e-03) 0.011699945107107979, 0.004558454737796746 ${e}_{III}$ The probability of the subscripted error acting on the specified labels. 9.4e-01 (4.9e-03) 0.9406753066583258, 0.0049020264565428915 ${p}_{ZZZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 8.8e-01 (2.1e-02) 0.8778171284215314, 0.021167748750971577 ${p}_{ZZX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (4.5e-03) 0.948673287227443, 0.004529707086937106 ${p}_{ZXZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (4.5e-03) 0.946629922951542, 0.004471446732253854 ${p}_{ZXY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01 (8.3e-03) 0.9178570830918114, 0.008336742277313566 ${p}_{ZXX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.0e-01 (1.3e-02) 0.904939725756637, 0.013122659139390978 ${p}_{ZXI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (3.3e-03) 0.9397087562888965, 0.003314684577019876 ${p}_{ZIZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01 (4.6e-03) 0.9342970814555008, 0.0046203488039331 ${p}_{ZII}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (1.5e-03) 0.960389515641083, 0.0015197434290932814 ${p}_{YZY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.1e-01 (9.2e-03) 0.9063934016373328, 0.009192217119963684 ${p}_{YYY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01 (9.3e-03) 0.9209062078857914, 0.00932005659179143 ${p}_{YYI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.0e-01 (1.4e-02) 0.8961444332376696, 0.01419033604586991 ${p}_{YIY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.1e-01 (9.3e-03) 0.9052343851230582, 0.009265692306516552 ${p}_{YIX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (6.0e-03) 0.939884541345959, 0.005995197001144808 ${p}_{XYI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (5.9e-03) 0.9390470133438547, 0.0058590704791723165 ${p}_{XXY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.3e-03) 0.9606246349084654, 0.0033432430873495426 ${p}_{XXX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.7e-03) 0.960379054148023, 0.0036964560753722825 ${p}_{XIZ}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (2.6e-03) 0.9607354126233814, 0.0026187505210687697 ${p}_{XIY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (6.5e-03) 0.9397244401206025, 0.006468302725636417 ${p}_{IZX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (1.4e-03) 0.9791986276596473, 0.0014217595890347462 ${p}_{IYI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (3.9e-03) 0.9398063147364136, 0.0038780382219142694 ${p}_{IXI}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (7.9e-04) 0.9809284415442054, 0.0007946364201698768 ${p}_{IIY}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01 (3.0e-03) 0.9377843291628644, 0.0030429570134895487 ${p}_{IIX}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (9.2e-04) 0.9791036214881103, 0.0009228156135803154 ${p}_{III}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00 (1.6e-21) 1.0, 1.5591363342197772e-21 ${A}_{ZZZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.1e+00 (2.0e-01) 1.123755162168166, 0.19721062425294683 ${A}_{ZZX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 8.8e-01 (4.3e-02) 0.879175501322384, 0.042526762323276734 ${A}_{ZXZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 8.9e-01 (3.8e-02) 0.8939374389930288, 0.03796975471647425 ${A}_{ZXY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (7.3e-02) 0.9867333044569134, 0.0725540542212821 ${A}_{ZXX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.1e+00 (1.2e-01) 1.1211505526070644, 0.12037496954441856 ${A}_{ZXI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00 (2.9e-02) 0.995357398892783, 0.028659678077831385 ${A}_{ZIZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.1e-01 (3.8e-02) 0.911480709234707, 0.03793803164902658 ${A}_{ZII}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (1.4e-02) 0.9911877888374598, 0.014156047374888082 ${A}_{YZY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (8.0e-02) 0.9770218209548845, 0.08044338839751888 ${A}_{YYY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (7.4e-02) 0.9457859327219312, 0.07379640105239452 ${A}_{YYI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (1.2e-01) 0.9842097121888828, 0.11841557737002678 ${A}_{YIY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (7.5e-02) 0.9458143996668499, 0.07454735792375403 ${A}_{YIX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (5.0e-02) 0.9557389837373932, 0.05011545938936463 ${A}_{XYI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01 (5.1e-02) 0.9498783537394647, 0.05107101441805456 ${A}_{XXY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.1e-02) 0.9587306970237476, 0.031489865176374705 ${A}_{XXX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (3.2e-02) 0.9702429480507555, 0.03200094119878441 ${A}_{XIZ}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (2.8e-02) 0.9676837719622322, 0.027880870010087957 ${A}_{XIY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (5.4e-02) 0.9853884063882858, 0.05421689273322557 ${A}_{IZX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (1.5e-02) 0.9697988320518097, 0.014699520487465824 ${A}_{IYI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01 (3.4e-02) 0.9551016324161047, 0.03425255381732674 ${A}_{IXI}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01 (8.7e-03) 0.9729016940157551, 0.008738778552891121 ${A}_{IIY}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01 (2.6e-02) 0.9934322327132123, 0.026419578640157246 ${A}_{IIX}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01 (9.3e-03) 0.9831057114833658, 0.009334806851247338 ${A}_{III}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00 (2.9e-20) 1.0, 2.86881085496439e-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])


## 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]:


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()


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. 5.5e-02+0.0e+00j (5.3e-03) (0.05547022319814354+0j), 0.005303211414447463 ${e}_{W00W00W00}$ The probability of the subscripted error acting on the specified labels. 9.4e-01+0.0e+00j (5.3e-03) (0.9445297768018565+0j), 0.005303211414447463 ${p}_{W22W22W22}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01+1.4e-02j (6.9e-03) (0.9317451162630211+0.014486227000873805j), 0.006919459124913566 ${p}_{W22W22W02}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01+3.1e-02j (9.6e-03) (0.9222169132985099+0.03094680073191182j), 0.009593537478195727 ${p}_{W22W11W02}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01-4.7e-03j (1.0e-02) (0.9256104675354334-0.004736361199420803j), 0.01042419255295761 ${p}_{W21W02W20}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01-1.3e-02j (3.7e-03) (0.9524378271671525-0.01258119175602841j), 0.0037134237874884243 ${p}_{W21W00W01}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-3.1e-02j (4.9e-03) (0.940063812895833-0.030531543871445275j), 0.004932012049730124 ${p}_{W20W21W02}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01-1.1e-02j (3.7e-03) (0.954785805306464-0.010586102446669342j), 0.0037001573495408224 ${p}_{W20W20W11}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01-2.0e-03j (2.7e-03) (0.9622638869679484-0.0019593650877883445j), 0.0026952262693079434 ${p}_{W20W20W00}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01+3.4e-04j (1.7e-03) (0.978379182579593+0.00034015169435055537j), 0.0017011558098534104 ${p}_{W20W00W11}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01-1.9e-02j (4.2e-03) (0.9494340074679993-0.01908659080189391j), 0.00424623182921645 ${p}_{W12W11W21}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01+1.2e-02j (6.9e-03) (0.9330763127836066+0.011770259035635703j), 0.006865319367391272 ${p}_{W12W10W20}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01+2.0e-02j (5.7e-03) (0.9387717867273145+0.020222565594714092j), 0.005709238473460663 ${p}_{W11W20W01}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01-1.5e-02j (3.6e-03) (0.9568254087208067-0.014880608513021993j), 0.0036303205720860797 ${p}_{W11W12W12}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01-2.0e-02j (7.6e-03) (0.9275390811293023-0.019550078965302965j), 0.007556147844028586 ${p}_{W11W10W12}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01-1.5e-02j (7.1e-03) (0.928901508365858-0.015417890418881725j), 0.007097870057466858 ${p}_{W11W01W00}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-3.4e-02j (4.5e-03) (0.9391623105289942-0.03423948920188972j), 0.004455226467911361 ${p}_{W10W11W21}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01-2.2e-04j (2.9e-03) (0.9622085518595513-0.0002236673579821581j), 0.002910686734103385 ${p}_{W10W00W00}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00-4.8e-05j (1.5e-04) (1.0000288585346535-4.838950192640656e-05j), 0.0001536710954625937 ${p}_{W02W22W11}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01+1.2e-02j (5.8e-03) (0.9355980729735758+0.011716703122365672j), 0.005770677259950233 ${p}_{W02W00W12}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01+3.3e-02j (8.9e-03) (0.9224647529251154+0.03322436353710011j), 0.008902721122659362 ${p}_{W01W22W21}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01-1.5e-02j (5.9e-03) (0.9329705583456841-0.014553186008249229j), 0.00589764255501286 ${p}_{W01W01W20}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01-1.9e-02j (3.9e-03) (0.9523199086173564-0.019085420305382215j), 0.003923652755089202 ${p}_{W01W00W11}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01-2.5e-02j (8.4e-03) (0.9196136493297269-0.0246151176741659j), 0.008442726548934994 ${p}_{W00W11W02}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01-1.9e-02j (3.8e-03) (0.9502957493881796-0.019225140688721085j), 0.00381518591427333 ${p}_{W00W11W00}$ Decay parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.5e-01-1.5e-02j (1.6e-03) (0.952001113532874-0.014870845956956976j), 0.0016133301889586986 ${A}_{W22W22W22}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01-2.2e-02j (5.3e-02) (0.9842644538633487-0.022009799480935146j), 0.053114889859190995 ${A}_{W22W22W02}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-4.1e-02j (7.0e-02) (0.9444353230317426-0.041256658473469585j), 0.06981285285023418 ${A}_{W22W11W02}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01+6.1e-03j (7.2e-02) (0.9333013323851856+0.006052052071489763j), 0.07214447022999863 ${A}_{W21W02W20}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.6e-01-5.8e-02j (3.2e-02) (0.9606620480325718-0.05784255809994283j), 0.03242794000001283 ${A}_{W21W00W01}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 1.0e+00-2.0e-03j (4.1e-02) (1.0047489743383675-0.002029705485428301j), 0.04138958982569204 ${A}_{W20W21W02}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-7.0e-02j (3.0e-02) (0.9397577021685537-0.06970346421018732j), 0.03014143788449757 ${A}_{W20W20W11}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-1.2e-02j (2.4e-02) (0.9361479128038167-0.011909384598645994j), 0.023768638678230033 ${A}_{W20W20W00}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.8e-01-2.2e-02j (1.7e-02) (0.975281461758298-0.02231931416807594j), 0.01725619598593713 ${A}_{W20W00W11}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01-8.2e-03j (3.5e-02) (0.9708220774277684-0.008198124403209618j), 0.03498372120571515 ${A}_{W12W11W21}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01+6.7e-03j (5.2e-02) (0.9318260390851716+0.006720450840069328j), 0.0515870162156299 ${A}_{W12W10W20}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-3.5e-02j (4.3e-02) (0.9406837629091986-0.03452580869602096j), 0.04335375953595547 ${A}_{W11W20W01}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.0e-01-5.7e-02j (3.0e-02) (0.9019228019436182-0.056864745322726j), 0.029867037694763027 ${A}_{W11W12W12}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01+8.4e-03j (5.8e-02) (0.9896753580326073+0.008412517187315312j), 0.05818429231281991 ${A}_{W11W10W12}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01-3.6e-02j (5.4e-02) (0.9716174163468427-0.0363935991113089j), 0.05387932347545365 ${A}_{W11W01W00}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01-1.1e-02j (3.9e-02) (0.9943951830259984-0.010891602277368741j), 0.03913582818679368 ${A}_{W10W11W21}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-1.9e-02j (2.6e-02) (0.9361197186492418-0.01944466200054859j), 0.025514062219020164 ${A}_{W10W00W00}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01+3.4e-03j (2.5e-03) (0.9855133925650335+0.00338093792019262j), 0.0024747406960594965 ${A}_{W02W22W11}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-4.8e-03j (4.5e-02) (0.9430581766740781-0.004775785267787633j), 0.045061543091055194 ${A}_{W02W00W12}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.3e-01+3.9e-02j (6.5e-02) (0.9331860658044517+0.038726083013374976j), 0.06532868321181029 ${A}_{W01W22W21}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.2e-01-5.0e-02j (4.7e-02) (0.9228802596840943-0.05032052713743616j), 0.04690143270162386 ${A}_{W01W01W20}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.4e-01-6.6e-03j (3.2e-02) (0.9432505184220916-0.006635880388749142j), 0.031556846756995126 ${A}_{W01W00W11}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01-3.3e-02j (6.7e-02) (0.989885281363909-0.033133096887692615j), 0.0666222544701475 ${A}_{W00W11W02}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.9e-01+6.3e-03j (3.1e-02) (0.9917076985626475+0.00627027510314916j), 0.0314424945270913 ${A}_{W00W11W00}$ SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term. 9.7e-01-1.4e-02j (1.3e-02) (0.9745457389071142-0.014418977310980404j), 0.013288536731109172