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 Protocols.

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 Protocols.

  2. Iterate through the circuit objects and perform them experimentally, recording their Results. See Examples for a number of worked examples using the Simulator.

  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: (('C', 0),) protocol: SRB compiled_pauli: X n_random_cycles: 4 Labels: (0,) Name: Gate.cliff23 Aliases: Gate.cliff23 Generators: Z: 69.28 X: 69.28 Y: 69.28 0.50 -0.50j -0.50 -0.50j 0.50 -0.50j 0.50 0.50j 23 Imm Labels: (0,) Name: Gate.cliff16 Aliases: Gate.cliff16 Generators: Y: -69.28 X: -69.28 Z: -69.28 0.50 0.50j 0.50 0.50j -0.50 0.50j 0.50 -0.50j 16 Imm Labels: (0,) Name: Gate.cliff19 Aliases: Gate.cliff19 Generators: X: -69.28 Y: 69.28 Z: 69.28 0.50 -0.50j -0.50 0.50j 0.50 0.50j 0.50 0.50j 19 Imm Labels: (0,) Name: Gate.cliff16 Aliases: Gate.cliff16 Generators: Y: -69.28 X: -69.28 Z: -69.28 0.50 0.50j 0.50 0.50j -0.50 0.50j 0.50 -0.50j 16 Imm Labels: (0,) Name: Gate.cliff19 Aliases: Gate.cliff19 Generators: X: -69.28 Y: 69.28 Z: 69.28 0.50 -0.50j -0.50 0.50j 0.50 0.50j 0.50 0.50j 19 Imm 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='X', n_random_cycles=4, protocol='SRB', twirl=(('C', 0),))

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 groups used on each subsystem. Possible groups are: "P" (Pauli), "C" (Clifford), "SU" (special unitary), or "I" (Identity). A mixture of groups on different labels can be specified by an iterable of groups and labels, for example, [["P", 0], ["C", 1, 2], ["C", 3]], where ["C", 1, 2] specifies the two-qubit Clifford group acting on the labels [1, 2] and ["C", 3] specifies the one-qubit Clifford group acting on the label 3. Warning: "I" is provided as a convenience method for expert users to identify coherent errors and/or crosstalk even though an exponential decay is not expected.

compiled_pauli -

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

n_bodies -

The number of gate bodies to reconstruct marginal probability distributions for.

seq_label -

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

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()
KeySet
List of all the keys in the KeySet
protocol
The characterization protocol used to generate a circuit.
twirl
The twirling groups used on each subsystem.
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.
Key
Key:
  • compiled_pauli: I
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 4 I
Key
Key:
  • compiled_pauli: X
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 4 X
Key
Key:
  • compiled_pauli: Y
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 4 Y
Key
Key:
  • compiled_pauli: Z
  • n_random_cycles: 4
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 4 Z
Key
Key:
  • compiled_pauli: I
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 32 I
Key
Key:
  • compiled_pauli: X
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 32 X
Key
Key:
  • compiled_pauli: Y
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 32 Y
Key
Key:
  • compiled_pauli: Z
  • n_random_cycles: 32
  • protocol: SRB
  • twirl: (('C', 0),)
SRB (('C', 0),) 32 Z