# Interleaved randomized benchmarking (IRB)¶

import trueq as tq

# Define some cycles that define the gates we want to characterize with IRB
# Note that we could perform simultaneous IRB with,
# e.g. {(1, 2): tq.Gate.cz, (3, 4): tq.Gate.cz}
cycle1 = {1: tq.Gate.h}
cycle2 = {2: tq.Gate.h}
cycle12 = {(1, 2): tq.Gate.cz}

# Generate a circuit collection to run IRB on the above cycle
# with 30 random circuits for each circuit length in [4, 32, 64].
circuits = tq.make_irb(cycle1, [4, 32, 64])
circuits.append(tq.make_irb(cycle2, [4, 32, 64]))
circuits.append(tq.make_irb(cycle12, [4, 32, 64]))

# We are interested in the gate fidelity of e.g. CZ alone, so we also need a reference
# SRB experiment. Optionally, to tighten the bound on the infidelity estimate, we
# also do an XRB experiment. The double nesting [[1, 2]] is necessary because just
# [1, 2] refers to simultaneous 1-qubit gates.
circuits.append(tq.make_srb(, [4, 20, 50]))
circuits.append(tq.make_srb(, [4, 20, 50]))
circuits.append(tq.make_srb([[1, 2]], [4, 20, 50]))
circuits.append(tq.make_xrb(, [4, 20, 50]))
circuits.append(tq.make_xrb(, [4, 20, 50]))
circuits.append(tq.make_xrb([[1, 2]], [4, 20, 50]))

# Create a noisy simulator and populate all results

# Plot a summary of information
circuits.plot.irb_summary() # Print a summary of the results for the CZ gate
circuits.fit(twirl=(("C", 1, 2),))

IRB on [1, 2]
Name
Estimate
95% CI

Description
r
2.305
[2.067,2.543]
e-02
Average gate infidelity of the composite error map (interleaved gate composed with random twirling element)
r_l
3.284
[1.534,5.034]
e-03
Lower bound on the interleaved gate's average gate infidelity
r_u
3.709
[2.643,4.774]
e-02
Upper bound on the interleaved gate's average gate infidelity
A
0.995
[0.961,1.029]
SPAM of the exponential decay A * p ** m
p
0.969
[0.966,0.972]
Decay rate of the exponential decay A * p ** m
SRB on [1, 2]
Name
Estimate
95% CI

Description
r
1.213
[1.088,1.337]
e-02
Average gate infidelity of the error map
A
1.001
[0.983,1.019]
SPAM of the exponential decay A * p ** m
p
0.984
[0.982,0.985]
Decay rate of the exponential decay A * p ** m
XRB on [1, 2]
Name
Estimate
95% CI

Description
ru
7.549
[5.406,9.693]
e-03
Average gate infidelity of systematic coherent error, d * (1 - sqrt(u)) / (d - 1), so that it is bounded between 0 and r from SRB
inc
0.623
[0.435,0.810]
Incoherence, 0 indicates entirely unitary noise and 1 indicates entirely depolarizing noise
A
0.473
[0.387,0.560]
SPAM of the exponential decay A * u ** m
u
0.980
[0.974,0.986]
Decay rate of the exponential decay A * u ** m

Total running time of the script: ( 0 minutes 5.004 seconds)

Gallery generated by Sphinx-Gallery