# Assessments¶

trueq.assessments.make_crosstalk_diagnostics(labels, n_random_cycles, n_circuits=30, subsets=None, include_xrb=True, simul_ratio=0.5, isol_inc=1, simul_inc=0.8, twirling_group=None)

Generates a circuit collection to measure the discrepancy between gate quality while applying gates simultaneously versus while applying gates in an isolated way to each individual system (qubit). This is done by running SRB simultaneously on the specified systems, as well as running it on each system in turn. Optionally, and true by default, this is also done with XRB.

One can choose to do any combination of single-qubit twirling or two-qubit twirling on the labels. For instance, setting labels as [[4], [5, 6]] indicates single-qubit twirling on qubits 4 and two-qubit twirling on qubits (5,6).

import trueq as tq

# generate a circuit collection to run cross-talk diagnostics in single qubit
# mode for qubits 5, 6, 7, and 8
circuits = tq.make_crosstalk_diagnostics([5, 6, 7, 8], [4, 100])

# if we think that simultaneous gates will make the gates at most 5 times worse,
circuits = tq.make_crosstalk_diagnostics(
[5, 6, 7, 8], [4, 100], simul_ratio=0.2
)

# reduce the number of circuits to perform by excluding XRB circuits
# this means we cannot learn about incoherence when analyzing data
circuits = tq.make_crosstalk_diagnostics(
[5, 6, 7, 8], [4, 100], include_xrb=False
)

# we can also specify that some pairs of qubits undergo two-qubit gates
circuits = tq.make_crosstalk_diagnostics(
[5, [6, 7], 8], [4, 100], include_xrb=False
)

# using the subsets option, we can customize exactly which subsets of the full
# simultaneous twirl are performed in isolation. here, the default value would
# have resulted in subsets [[5],[6],[[7, 8]]]
circuits = tq.make_crosstalk_diagnostics(
[5, 6, [7, 8]], [4, 100], include_xrb=False, subsets=[[5], [5, 6], [[7, 8]]]
)

Parameters
• labels (Iterable) – A list of (lists of) positive integers, specifying qubit labels in each circuit, e.g. [3, [1, 2], 4]. As with make_srb(), pairs of labels within indicate 2-qubit gates should be used on those qubits.

• n_random_cycles (Iterable) – A list of positive integers, specifying how many random cycles will be generated during the protocol, e.g. [6, 20].

• subsets (Iterable) – A list of subsets of the given labels to be used. The default value of None results in each subset being a member of the given labels. See the last example above.

• include_xrb – Whether to include XRB circuits in the output.

• simul_ratio (float | Iterable) – The expected average ratio between the infidelity of isolated gates and the infidelity of simultaneous gates. For example, if you expect your isolated SRB infidelity to be 0.001 and your simultaneous SRB infidelity on the same qubit to be 0.005, then you should set simul_ratio=0.2. Alternatively, this can also be a list of sequence lengths you wish to use for simultaneous SRB.

• isol_inc (float | Iterable) – The expected average incoherence of gates performed in isolation. For example, if you expect that 10% of your gate noise (when performed in an isolated way) is unitary (ex. overrotation), then set isol_inc=0.9. Alternatively, this can also be a list of sequence lengths you wish to use for isolated XRB. This parameter is ignored if include_xrb is false.

• simul_inc (float | Iterable) – The expected average incoherence of gates performed simultaneously. For example, if you expect that 10% of your gate noise (when performed in an isolated way) is unitary (ex. overrotation), then set simul_inc=0.9. Alternatively, this can also be a list of sequence lengths you wish to use for isolated XRB. This parameter is ignored if include_xrb is false.

• n_circuits (int) – The number of circuits for at each n_random_cycles for each protocol.

• twirling_group (Iterable) – The twirling group to use in this protocol. This can be one of "SU" (special unitary), "C" (Clifford), or a mixture such as [["SU", 0], ["C", 1, 2], ["C", 3], ["SU", 4, 6]]. If the twirling group is not specified or if some labels are omitted in the specification, they will be populated from labels with "C" by default.

Return type

CircuitCollection

trueq.assessments.make_qcap(circuit, n_random_cycles, n_circuits=30, n_decays=20)

Generates circuits to measure the quantum capacity (QCAP) bound of the provided circuit. This scalable protocol bounds the circuit performance when the circuit is performed under randomized compiling (see randomly_compile()). Circuit performance, here, is measured by the total variational distance (TVD) between the ideal bitstring probabilities of the output state and the measured bitstring probabilities.

Analyze results by calling qcap_bound() on the QCAP circuits once they have been performed and their results have been populated. Note that this function outputs cycle benchmarking circuits, and fit() will report individual infidelities of the cycles in your circuit.

import trueq as tq

# make a circuit to assess
circuit = tq.Circuit([
{0: tq.Gate.y},
{(0, 1): tq.Gate.cnot},
{0: tq.Gate.h, 1: tq.Gate.h},
{(1, 2): tq.Gate.cnot, (3, 4): tq.Gate.cnot},
{0: tq.Gate.h, 1: tq.Gate.h},
{(1, 2): tq.Gate.cnot, (3, 4): tq.Gate.cnot},
{0: tq.Gate.h, 1: tq.Gate.h},
{(1, 3): tq.Gate.cnot}
])

# generate a circuit collection to measure the QCAP
circuits = tq.assessments.make_qcap(circuit, [0, 4, 16, 32])

# run the circuits on your hardware or simulator

# generate the QCAP bound
tq.assessments.qcap_bound(circuit, circuits)

Parameters
• cycle (Circuit) – The circuit to measure the QCAP bound of.

• n_random_cycles (Iterable) – A list of positive integers, specifying how many random cycles will be generated during the protocol, e.g. [6, 20].

• n_circuits (int) – The number of circuits for each random cycle.

• n_decays (int) – An integer specifying the total number of randomly chosen pauli decay strings used to measure the process infidelity. Setting this value lower than min(20, 4 ** n_qubits - 1) may result in a biased estimate.

Return type

CircuitCollection

trueq.assessments.qcap_bound(circuit, circuits)

Computes the quantum capacity (QCAP) bound of circuits generated by make_qcap(). This scalar quantity is a bound on circuit performance when the circuit is performed under randomized compiling (see randomly_compile()). Circuit performance, here, is measured by the total variational distance (TVD) between the ideal bitstring probabilities of the output state and the measured bitstring probabilities.

Parameters
Return type

Parameter