Introduction to Protocols

True-Q™ provides a number of diagnostic and assessment protocols for generating and characterizing gates, cycles and full circuits. These protocols are described in detail in Error Diagnostics.

To get a sense of what these different protocol methods create, here is a simple example generating circuits for single qubit Streamlined Randomized Benchmarking (SRB) experiment:

import trueq as tq

circuits = tq.make_srb(labels=[0], n_random_cycles=[4, 32], n_circuits=25)

In this example circuits is a single qubit CircuitCollection, a collection of circuits to be run. The CircuitCollection object is essentially an iterable object of Circuits, each of which describes a single circuit to be run on a quantum device. A circuit stores both the quantum operations to be performed in each cycle of the circuit, and the experimental or simulated results once it has been run.

There are three essential steps for every protocol:

  1. Generate a circuit collection using a function such as make_srb() as above or any of the other functions in Error Diagnostics.

  2. Iterate through the circuit objects and perform them experimentally, recording their worked examples using any of the methods outlined in Running Circuits.

  3. Analyze the data using the fit() method of the circuit collection.

Inspecting Generated Circuits

Since a CircuitCollection is effectively a list of circuits, individual circuits can be inspected using standard list indexing:

circuits[0].draw()
0 Key: twirl: Cliffords on [0] protocol: SRB compiled_pauli: Y n_random_cycles: 4 measurement_basis: Z 1 Labels: (0,) Name: Gate.cliff16 Aliases: Gate.cliff16 Generators: X: -69.28 Z: -69.28 Y: -69.28 0.71 0.71 0.71j -0.71j 16 2 Labels: (0,) Name: Gate.sy Aliases: Gate.sy Gate.cliff7 Generators: Y: 90.00 0.50 0.50j -0.50 -0.50j 0.50 0.50j 0.50 0.50j SY 3 Labels: (0,) Name: Gate.x Aliases: Gate.x Gate.cliff1 Generators: X: 180.00 -1.00j -1.00j X 4 Labels: (0,) Name: Gate.cliff19 Aliases: Gate.cliff19 Generators: X: -69.28 Z: 69.28 Y: 69.28 0.50 -0.50j -0.50 0.50j 0.50 0.50j 0.50 0.50j 19 5 Labels: (0,) Name: Gate.sy Aliases: Gate.sy Gate.cliff7 Generators: Y: 90.00 0.50 0.50j -0.50 -0.50j 0.50 0.50j 0.50 0.50j SY 6 Labels: (0,) Name: Meas M

Every circuit generated using a make_* protocol in True-Q™ additionally contains a Key used to store information about the generation method used. This meta data can be viewed using trueq.Circuit.key.

circuits[0].key
Key(compiled_pauli=Weyls('Y'), measurement_basis=Weyls('Z'), n_random_cycles=4, protocol='SRB', twirl=Twirl({(0,): 'C'}, dim=2))

The Key of each circuit is essentially a hashable frozen dictionary containing data about how the circuits were generated. This information is used internally by True-Q™ during analysis, but it is often useful for the user to be able to read them. Some of the more frequently generated keys entries are listed below:

protocol -

The characterization protocol used to generate a circuit.

cycle -

A “clock cycle” of a circuit; a set of operations that happen in parallel to a disjoint set of systems.

n_random_cycles -

The number of independent random cycles in the circuit.

measurement_basis -

An n-qubit Pauli operator describing the change-of-basis gates added prior to measurement.

twirl -

The twirling group used to generate a circuit.

compiled_pauli -

The n-qubit Pauli operator that was compiled into the circuit immediately before measurement.

seq_label -

A number to group related sequences used internally by some fitting tools.

subsystems -

The subsystems to analyze for a given protocol.

Each circuit generated by one of the protocol generation methods will have its own key. All keys present in any CircuitCollection can be viewed using its keys() method. Here we can view all keys present in the SRB circuit collection created above:

circuits.keys()
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".
KeySet
List of all the keys in the KeySet
protocol
The characterization protocol used to generate a circuit.
twirl
The twirling group used to generate a circuit.
n_random_cycles
The number of independent random cycles in the circuit.
compiled_pauli
The n-qubit Pauli operator that was compiled into the circuit immediately before measurement.
measurement_basis
An n-qubit Pauli operator describing the change-of-basis gates added prior to measurement.
Key
Key:
  • compiled_pauli: Z
  • measurement_basis: Z
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 4 Z Z
Key
Key:
  • compiled_pauli: I
  • measurement_basis: Z
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 4 I Z
Key
Key:
  • compiled_pauli: Y
  • measurement_basis: Z
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 4 Y Z
Key
Key:
  • compiled_pauli: X
  • measurement_basis: Z
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 4 X Z
Key
Key:
  • compiled_pauli: X
  • measurement_basis: Z
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 32 X Z
Key
Key:
  • compiled_pauli: Y
  • measurement_basis: Z
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 32 Y Z
Key
Key:
  • compiled_pauli: Z
  • measurement_basis: Z
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 32 Z Z
Key
Key:
  • compiled_pauli: I
  • measurement_basis: Z
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: Cliffords on [0]
SRB Cliffords on [0] 32 I Z

Analyzing Results

To analyze the results of a given protocol, we call the fit() method, which is a universal function for CircuitCollections containing Circuits from any subset of True-Q™'s error diagnostic protocols. The fit() method returns estimates for the set of protocol-specific parameters.

In order to use the fit() method, we need to populate the Results attribute of each circuit in the collection (see Example: Recording Results).

Let’s walk through a quick example with our built-in Simulator:

import trueq as tq

# generate SRB circuits on a single qubit
circuit_collection = tq.make_srb(0, [4, 20, 60])

# create a noisy simulator
sim = tq.Simulator().add_overrotation(0.03)

# run the circuits on the noisy simulator and populate the results attribute
sim.run(circuit_collection)

Call the fit() method:

circuit_collection.fit()
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".
SRB
Streamlined Randomized Benchmarking
Cliffords
(0,)
Key:
  • labels: (0,)
  • protocol: SRB
  • twirl: Cliffords on [0]
${e}_{F}$
The probability of an error acting on the targeted systems during a random gate.
1.1e-03 (3.0e-04)
0.0011395518660511084, 0.00030399072166754665
${p}$
Decay parameter of the exponential decay $Ap^m$.
1.0e+00 (4.1e-04)
0.9984805975119319, 0.0004053209622233955
${A}$
SPAM parameter of the exponential decay $Ap^m$.
9.9e-01 (6.9e-03)
0.9885648343656012, 0.00685011251017943

The printed table contains the parameter estimates returned when the results are analyzed. Every protocol will return different estimates corresponding to the parameters the protocol is characterizing. Mousing over a parameter will give a short description of what the parameter means. If a circuit collection contains circuits from more than one error diagnostic protocol, fit will return fits for each protocol. For example, if we add some XRB circuits to the circuit collection we defined above, we get the following:

# generate XRB circuits and append them to the circuit_collection
circuit_collection += tq.make_xrb(1, [4, 20, 60])

# run circuits again to populate XRB circuits. We set overwrite = False to keep the
# results obtained above for the SRB circuits
sim.run(circuit_collection, overwrite=False)

# analyze results
circuit_collection.fit()
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".
SRB
Streamlined Randomized Benchmarking
Cliffords
(0,)
Key:
  • labels: (0,)
  • protocol: SRB
  • twirl: Cliffords on [0]
${e}_{F}$
The probability of an error acting on the targeted systems during a random gate.
1.3e-03 (3.3e-04)
0.0012775692314148934, 0.00032933168532588034
${p}$
Decay parameter of the exponential decay $Ap^m$.
1.0e+00 (4.4e-04)
0.9982965743581135, 0.00043910891376784043
${A}$
SPAM parameter of the exponential decay $Ap^m$.
9.9e-01 (6.4e-03)
0.9944756822495112, 0.006351754676315507
XRB
Extended Randomized Benchmarking
Cliffords
(1,)
Key:
  • labels: (1,)
  • protocol: XRB
  • twirl: Cliffords on [1]
${e}_{S}$
The probability of a stochastic error acting on the specified systems during a random gate.
2.9e-04 (2.7e-04)
0.0002882817766717283, 0.00027355188280991076
${u}$
The unitarity of the noise, that is, the average decrease in the purity of an initial state.
1.0e+00 (7.3e-04)
0.9992313594040524, 0.0007292613940989932
${A}$
SPAM parameter of the exponential decay $Au^m$.
1.0e+00 (1.6e-02)
1.0455044390189407, 0.016170308530726995

Optional Fitting Arguments

Valid options for the trueq.CircuitCollection.fit() method.

Certain analysis routines use optional arguments. The table below is an exhaustive list of possible arguments. These arguments can be passed into the fit() method as keyword arguments.

type

object

properties

  • analyze_dim

A small prime to be used as the qudit dimension during analysis. This can be used to account for leakage levels.

default

null

oneOf

type

null

type

number

oneOf

enum

2, 3, 5, 7

  • observables

A list of strings that specify the observables to compute expectation values of. The supported observables include computational basis states, e.g. '000', and Pauli/Weyl operators, e.g. 'ZIZ' for qubits or 'W01W02W00' for qudits.

type

array

default

items

type

string

pattern

^([\dIXYZ]|W\d\d)+$