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 singlequbit twirling or twoqubit twirling on the labels. For instance, setting
labels
as[[4], [5, 6]]
indicates singlequbit twirling on qubits 4 and twoqubit twirling on qubits (5,6).import trueq as tq # generate a circuit collection to run crosstalk 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, # then we should tell it about this ratio to get appropriate sequence lengths 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 twoqubit 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 withmake_srb()
, pairs of labels within indicate 2qubit 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 ofNone
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 setsimul_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 setisol_inc=0.9
. Alternatively, this can also be a list of sequence lengths you wish to use for isolated XRB. This parameter is ignored ifinclude_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 setsimul_inc=0.9
. Alternatively, this can also be a list of sequence lengths you wish to use for isolated XRB. This parameter is ignored ifinclude_xrb
is false.n_circuits (
int
) – The number of circuits for at eachn_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 fromlabels
with"C"
by default.
 Return type

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, andfit()
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 tq.Simulator().add_depolarizing(0.05).add_overrotation(0.05).run(circuits) # 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 thanmin(20, 4 ** n_qubits  1)
may result in a biased estimate.
 Return type

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 (seerandomly_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
circuit – The circuit you wish to know the QCAP bound of. This will usually be the original circuit that was given to
make_qcap()
, but can be any circuit whoseimmutable
cycles are a subset of the immutable cycles in the original circuit.circuits (
CircuitCollection
ParameterCollection
) – A circuit collection as output bymake_qcap()
. For efficiency, if you need to calculate many bounds based on the same dataset, this can also be the output ofcircuits.fit([circuit.labels], protocol="CB")
.
 Return type