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.
5.7e-02 (3.8e-03)
0.05690796360146544, 0.0037617445640224807
${e}_{III}$
The probability of the subscripted error acting on the specified labels.
9.4e-01 (3.8e-03)
0.9430920363985346, 0.0037617445640224807
${p}_{ZYY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.6e-03)
0.922377571779171, 0.009635891245838142
${p}_{ZYX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (6.0e-03)
0.9328634353596883, 0.006033011299242264
${p}_{ZXZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (5.6e-03)
0.9377019828441594, 0.0056098625221731304
${p}_{ZXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.8e-03)
0.9245525905174039, 0.00977068561679531
${p}_{ZXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (3.7e-03)
0.9416660350463725, 0.00372234848012085
${p}_{ZIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (9.4e-03)
0.9296116716030732, 0.009383541684944324
${p}_{ZII}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (1.6e-03)
0.9595842762386678, 0.0016462301525522038
${p}_{YZY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (1.6e-02)
0.9123658118754827, 0.015509355023915742
${p}_{YZI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (8.0e-03)
0.9303255517009124, 0.008033608587032153
${p}_{YYZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (8.3e-03)
0.9316305818219407, 0.0082795111635164
${p}_{YYY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (6.7e-03)
0.9381879743775329, 0.0067493985695082125
${p}_{YYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.0e-01 (8.2e-03)
0.9049297756862362, 0.008230335118353489
${p}_{YXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.6e-03)
0.92044794882096, 0.009637921762105399
${p}_{YIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (5.9e-03)
0.9314908756806474, 0.005912255024620556
${p}_{YIX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (6.3e-03)
0.9331456003901731, 0.006333469260312881
${p}_{XZX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (2.1e-03)
0.9799766870690595, 0.002115404842709196
${p}_{XXZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (2.5e-03)
0.9770022911471365, 0.0025310559683537496
${p}_{XXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.5e-03)
0.9628241345844247, 0.0035126822146096834
${p}_{XXX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.4e-03)
0.9573600958321203, 0.0034146619857173214
${p}_{XIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.5e-03)
0.9615166906826141, 0.0034503819465750408
${p}_{XII}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (1.8e-04)
0.9998055236994764, 0.00017945044434892874
${p}_{IZY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (6.6e-03)
0.9402053439970174, 0.006574732366654276
${p}_{IYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (2.4e-03)
0.9432857669352046, 0.002385485706739143
${p}_{IXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (2.1e-03)
0.9613506558753521, 0.00214567403897663
${A}_{ZYY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (8.1e-02)
0.9323933625385058, 0.08094624618693787
${A}_{ZYX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.7e-01 (5.1e-02)
0.8653101793449948, 0.05115095539255473
${A}_{ZXZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (4.9e-02)
0.9917253149376113, 0.04924417251017746
${A}_{ZXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (7.9e-02)
0.9791078926609246, 0.07893992095602002
${A}_{ZXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (3.4e-02)
0.9763618177129983, 0.03365938204550823
${A}_{ZIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.3e-02)
0.9313151309407692, 0.07271464182373386
${A}_{ZII}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (1.6e-02)
0.9941423904307718, 0.015530479235369826
${A}_{YZY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.5e-01 (1.1e-01)
0.8539099421883786, 0.1091456509028081
${A}_{YZI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.7e-01 (6.5e-02)
0.8749747636927109, 0.0652322791869941
${A}_{YYZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
7.9e-01 (6.3e-02)
0.7897746379569114, 0.06299199188226633
${A}_{YYY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
7.8e-01 (4.9e-02)
0.7818129401242467, 0.049180342517339284
${A}_{YYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (6.2e-02)
0.9096015198811617, 0.06237195011029491
${A}_{YXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.9e-02)
0.9348954050080318, 0.07940129990449313
${A}_{YIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.7e-01 (5.0e-02)
0.8741315547156413, 0.04996203181333043
${A}_{YIX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (5.7e-02)
0.9883653725359344, 0.0574076118688032
${A}_{XZX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01 (2.1e-02)
0.947881037228695, 0.020827785266218302
${A}_{XXZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (2.5e-02)
0.968658544168344, 0.02533069525348711
${A}_{XXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (3.2e-02)
0.9284301728468339, 0.03238968527673114
${A}_{XXX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (3.3e-02)
0.9845256770587802, 0.033229241517897024
${A}_{XIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (3.3e-02)
0.9657792881149486, 0.03296172606461058
${A}_{XII}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (2.8e-03)
0.9832116241560314, 0.00275914372330722
${A}_{IZY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (5.4e-02)
0.9418063218516172, 0.053619248273101196
${A}_{IYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (2.1e-02)
0.963444927379875, 0.020964493968615237
${A}_{IXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (2.0e-02)
0.9690069176527669, 0.01983320970752

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.
5.7e-02 (3.8e-03)
0.05690796360146544, 0.0037617445640224807
${e}_{ZII}$
The probability of the subscripted error acting on the specified labels.
-3.2e-03 (3.4e-03)
-0.003233231467648534, 0.003392332485929
${e}_{XII}$
The probability of the subscripted error acting on the specified labels.
1.7e-02 (3.0e-03)
0.01737767664316403, 0.002996689665930722
${e}_{IIZ}$
The probability of the subscripted error acting on the specified labels.
2.6e-03 (3.8e-03)
0.002620548858668914, 0.0038208433272683053
${e}_{IIX}$
The probability of the subscripted error acting on the specified labels.
4.5e-03 (4.1e-03)
0.004459061483363003, 0.004126726672503323
${e}_{III}$
The probability of the subscripted error acting on the specified labels.
9.4e-01 (3.8e-03)
0.9430920363985346, 0.0037617445640224807
${p}_{ZYY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.6e-03)
0.922377571779171, 0.009635891245838142
${p}_{ZYX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (6.0e-03)
0.9328634353596883, 0.006033011299242264
${p}_{ZXZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (5.6e-03)
0.9377019828441594, 0.0056098625221731304
${p}_{ZXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.8e-03)
0.9245525905174039, 0.00977068561679531
${p}_{ZXI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (3.7e-03)
0.9416660350463725, 0.00372234848012085
${p}_{ZIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (9.4e-03)
0.9296116716030732, 0.009383541684944324
${p}_{ZII}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (1.6e-03)
0.9595842762386678, 0.0016462301525522038
${p}_{YZY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (1.6e-02)
0.9123658118754827, 0.015509355023915742
${p}_{YZI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (8.0e-03)
0.9303255517009124, 0.008033608587032153
${p}_{YYZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (8.3e-03)
0.9316305818219407, 0.0082795111635164
${p}_{YYY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (6.7e-03)
0.9381879743775329, 0.0067493985695082125
${p}_{YYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.0e-01 (8.2e-03)
0.9049297756862362, 0.008230335118353489
${p}_{YXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01 (9.6e-03)
0.92044794882096, 0.009637921762105399
${p}_{YIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (5.9e-03)
0.9314908756806474, 0.005912255024620556
${p}_{YIX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (6.3e-03)
0.9331456003901731, 0.006333469260312881
${p}_{XZX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (2.1e-03)
0.9799766870690595, 0.002115404842709196
${p}_{XXZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (2.5e-03)
0.9770022911471365, 0.0025310559683537496
${p}_{XXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.5e-03)
0.9628241345844247, 0.0035126822146096834
${p}_{XXX}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.4e-03)
0.9573600958321203, 0.0034146619857173214
${p}_{XIZ}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (3.5e-03)
0.9615166906826141, 0.0034503819465750408
${p}_{XII}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00 (1.8e-04)
0.9998055236994764, 0.00017945044434892874
${p}_{IZY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (6.6e-03)
0.9402053439970174, 0.006574732366654276
${p}_{IYI}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (2.4e-03)
0.9432857669352046, 0.002385485706739143
${p}_{IXY}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (2.1e-03)
0.9613506558753521, 0.00214567403897663
${A}_{ZYY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (8.1e-02)
0.9323933625385058, 0.08094624618693787
${A}_{ZYX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.7e-01 (5.1e-02)
0.8653101793449948, 0.05115095539255473
${A}_{ZXZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (4.9e-02)
0.9917253149376113, 0.04924417251017746
${A}_{ZXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (7.9e-02)
0.9791078926609246, 0.07893992095602002
${A}_{ZXI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (3.4e-02)
0.9763618177129983, 0.03365938204550823
${A}_{ZIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.3e-02)
0.9313151309407692, 0.07271464182373386
${A}_{ZII}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (1.6e-02)
0.9941423904307718, 0.015530479235369826
${A}_{YZY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.5e-01 (1.1e-01)
0.8539099421883786, 0.1091456509028081
${A}_{YZI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.7e-01 (6.5e-02)
0.8749747636927109, 0.0652322791869941
${A}_{YYZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
7.9e-01 (6.3e-02)
0.7897746379569114, 0.06299199188226633
${A}_{YYY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
7.8e-01 (4.9e-02)
0.7818129401242467, 0.049180342517339284
${A}_{YYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01 (6.2e-02)
0.9096015198811617, 0.06237195011029491
${A}_{YXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (7.9e-02)
0.9348954050080318, 0.07940129990449313
${A}_{YIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.7e-01 (5.0e-02)
0.8741315547156413, 0.04996203181333043
${A}_{YIX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01 (5.7e-02)
0.9883653725359344, 0.0574076118688032
${A}_{XZX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01 (2.1e-02)
0.947881037228695, 0.020827785266218302
${A}_{XXZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (2.5e-02)
0.968658544168344, 0.02533069525348711
${A}_{XXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01 (3.2e-02)
0.9284301728468339, 0.03238968527673114
${A}_{XXX}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (3.3e-02)
0.9845256770587802, 0.033229241517897024
${A}_{XIZ}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (3.3e-02)
0.9657792881149486, 0.03296172606461058
${A}_{XII}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01 (2.8e-03)
0.9832116241560314, 0.00275914372330722
${A}_{IZY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01 (5.4e-02)
0.9418063218516172, 0.053619248273101196
${A}_{IYI}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01 (2.1e-02)
0.963444927379875, 0.020964493968615237
${A}_{IXY}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01 (2.0e-02)
0.9690069176527669, 0.01983320970752

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.4e-02-0.0e+00j (5.5e-03)
(0.06355346718988375-0j), 0.0054591406334441005
${e}_{W00W00W00}$
The probability of the subscripted error acting on the specified labels.
9.4e-01+0.0e+00j (5.5e-03)
(0.9364465328101163+0j), 0.0054591406334441005
${p}_{W22W21W12}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01+1.9e-02j (6.7e-03)
(0.9343637822105585+0.019286611579327907j), 0.006746344346292756
${p}_{W22W21W01}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01+5.2e-03j (1.0e-02)
(0.9194067732439285+0.0052192675566885j), 0.010437991685236592
${p}_{W22W11W02}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01+2.0e-03j (1.1e-02)
(0.9087119015997073+0.0019656664563503087j), 0.011174207022459038
${p}_{W21W22W22}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-1.3e-02j (6.9e-03)
(0.9300405433792543-0.012814216481199762j), 0.006924781112700621
${p}_{W21W21W11}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-2.1e-02j (7.9e-03)
(0.9278809337695678-0.0211908718044275j), 0.00789055003622675
${p}_{W21W21W02}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-2.7e-02j (8.2e-03)
(0.9254197251042003-0.02670035767147625j), 0.008157916092575532
${p}_{W21W12W21}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.3e-01-2.3e-02j (8.2e-03)
(0.9286490755987749-0.022878334075636452j), 0.008211165287167619
${p}_{W21W11W22}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.2e-02j (6.7e-03)
(0.9359884739708114-0.01245208423475977j), 0.006688601567112437
${p}_{W21W02W02}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01+2.0e-02j (1.1e-02)
(0.9104235470929047+0.019662537032161625j), 0.01078205106607296
${p}_{W21W01W10}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-1.6e-02j (4.7e-03)
(0.950139442878285-0.015669885698496526j), 0.004678566623482234
${p}_{W21W01W01}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-5.4e-02j (6.2e-03)
(0.9241713374940375-0.05391508401269796j), 0.00622452982425976
${p}_{W20W12W20}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01+1.7e-03j (2.8e-03)
(0.9615951352557712+0.0016976602441787015j), 0.002756019297897818
${p}_{W20W02W02}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01+3.2e-02j (5.0e-03)
(0.9462017795952454+0.032151360216290004j), 0.004961744956132918
${p}_{W11W12W01}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01-3.7e-03j (1.2e-02)
(0.9095580373295221-0.003673092785926776j), 0.012170759789659816
${p}_{W11W02W10}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01-1.7e-02j (4.0e-03)
(0.9530354129412143-0.016881746072964818j), 0.004033531541697266
${p}_{W10W22W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01+1.7e-02j (4.2e-03)
(0.9475659712328105+0.017000627963711656j), 0.004174713831564204
${p}_{W10W12W11}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-1.4e-03j (3.2e-03)
(0.9625098254692048-0.001403777646663394j), 0.0031689180356652804
${p}_{W10W10W12}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-5.5e-04j (3.3e-03)
(0.9614912249459767-0.0005531211467296189j), 0.0032548654995551794
${p}_{W02W11W20}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01+2.1e-02j (5.6e-03)
(0.9395801808347319+0.020976859546053557j), 0.005597072521585537
${p}_{W02W01W02}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.1e-01+1.3e-02j (1.1e-02)
(0.9080575212040425+0.01262683152813598j), 0.010668610580708109
${p}_{W01W22W20}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.5e-02j (5.1e-03)
(0.9411315618459933-0.015451768299565235j), 0.0050806087828437
${p}_{W01W01W00}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-3.7e-02j (6.5e-03)
(0.9396886381230805-0.03714714263742118j), 0.006481310803663247
${p}_{W00W22W02}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.5e-01+2.1e-02j (2.7e-03)
(0.9513203770912374+0.021487057107328466j), 0.002653610817918688
${p}_{W00W11W22}$
Decay parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-2.6e-03j (3.1e-03)
(0.9577855852319345-0.0026204029487870498j), 0.003054837218719114
${A}_{W22W21W12}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-4.2e-02j (5.0e-02)
(0.9418723916565652-0.04174496140241286j), 0.0503100286788505
${A}_{W22W21W01}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00-5.0e-02j (7.7e-02)
(0.995750130752618-0.04958622563850864j), 0.07673156807679252
${A}_{W22W11W02}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.1e+00-4.3e-02j (8.8e-02)
(1.05178756657913-0.043208528885873426j), 0.08830487704394052
${A}_{W21W22W22}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.9e-01-4.6e-02j (5.3e-02)
(0.985585176920753-0.046344758867752245j), 0.05285913825334297
${A}_{W21W21W11}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00+2.0e-02j (6.0e-02)
(1.0014570783078378+0.0204038681912561j), 0.05966915726628663
${A}_{W21W21W02}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-5.4e-02j (6.0e-02)
(0.91839346514112-0.054020305417850696j), 0.060436838822283456
${A}_{W21W12W21}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-4.3e-03j (6.0e-02)
(0.9578287555594575-0.0043087691950847j), 0.059941389274922284
${A}_{W21W11W22}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.2e-01-3.9e-02j (4.9e-02)
(0.9200763435823877-0.038642806678967564j), 0.048665809140517324
${A}_{W21W02W02}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-1.6e-02j (8.0e-02)
(0.9649655411222666-0.015600570199091118j), 0.07990090871033922
${A}_{W21W01W10}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01-3.7e-02j (3.6e-02)
(0.9632761094989069-0.03746531915396832j), 0.03602812117564786
${A}_{W21W01W01}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.6e-01+3.1e-02j (4.9e-02)
(0.859538765778805+0.031116840286640645j), 0.049302672530779315
${A}_{W20W12W20}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-3.7e-02j (2.5e-02)
(0.9365399952019275-0.0374297958923849j), 0.02471148132962369
${A}_{W20W02W02}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-3.3e-02j (3.9e-02)
(0.9434923466653494-0.0328367895568372j), 0.03856481793676117
${A}_{W11W12W01}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00+3.1e-02j (9.4e-02)
(1.0483130220578738+0.031177408935052494j), 0.09416172441520734
${A}_{W11W02W10}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.3e-02j (3.1e-02)
(0.9365755180173899-0.013125642255726457j), 0.031150125131665433
${A}_{W10W22W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00-2.0e-02j (3.6e-02)
(0.9975030849248914-0.0199810620109369j), 0.03572747682384788
${A}_{W10W12W11}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-1.6e-02j (2.6e-02)
(0.9360133546646936-0.015616714973528623j), 0.026343453707157946
${A}_{W10W10W12}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.4e-01-2.5e-02j (2.8e-02)
(0.9443915763569746-0.024939927973028256j), 0.02797350024208503
${A}_{W02W11W20}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.8e-01-4.4e-02j (4.2e-02)
(0.8800242588227359-0.04416298179029433j), 0.04189695180316335
${A}_{W02W01W02}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
1.0e+00-1.6e-02j (8.2e-02)
(0.9956323337668709-0.015915220646623048j), 0.0816125960179585
${A}_{W01W22W20}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
8.8e-01-1.1e-02j (4.0e-02)
(0.8806904628043792-0.010720591041430132j), 0.03977503036431627
${A}_{W01W01W00}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.6e-01+2.7e-02j (4.8e-02)
(0.9620853598664773+0.027299587042063714j), 0.048125581794961785
${A}_{W00W22W02}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.7e-01-3.3e-02j (2.3e-02)
(0.9700552728615663-0.03266348336155915j), 0.023422601557424424
${A}_{W00W11W22}$
SPAM parameter of the exponential decay $Ap^m$ for the given Pauli term.
9.8e-01+9.1e-03j (2.6e-02)
(0.9764519311018193+0.009090102882325153j), 0.026303803174505758

Download

Download this file as Jupyter notebook: cb_example.ipynb.