GateCounts#

qualtran.resource_counting.GateCounts

A data class of counts of the typical target gates in a compilation.

Specifically, this class holds counts for the number of TGate (and adjoint), Toffoli, TwoBitCSwap, And, clifford bloqs, single qubit rotations, and measurements.

and_bloq

 

clifford

 

cswap

 

measurement

 

rotation

 

t

 

toffoli

 

Methods#

__add__

View source

__mul__

View source

__rmul__

View source

asdict

View source

total_t_count

View source

Get the total number of T Gates for the GateCounts object.

This simply multiplies each gate type by its cost in terms of T gates, which is configurable via the arguments to this method.

The default value for ts_per_rotation assumes the rotation is approximated using Mixed fallback protocol with error budget 1e-3.

total_t_and_ccz_count

View source

total_toffoli_only

View source

The number of Toffoli-like gates, and raise an exception if there are Ts/rotations.

to_legacy_t_complexity

View source

Return a legacy TComplexity object.

This coalesces all the gate types into t, rotations, and clifford fields. The conversion factors can be tweaked using the arguments to this method.

The argument cliffords_per_and_bloq sets the base number of clifford gates to add per self.and_bloq. To fully match the exact legacy t_complexity numbers, you must enable QECGatesCost(legacy_shims=True), which will enable a shim that directly adds on clifford counts for the X-gates used to invert the And control lines.

Warning: The number of Ts per Toffoli defaults to 4, whereas the number of Ts per CSwap defaults to 7. This preserves a legacy inconsistency. Really, these numbers should either both be 7 or both be 4 for a proper accounting. In total_t_count, we default to 4 T gates per CSwap or Toffoli. See https://github.com/quantumlib/Qualtran/issues/1463 for more discussion.

total_beverland_count

View source

Counts used by Beverland et al. using notation from the reference.

  • \(M_\mathrm{meas}\) is the number of measurements.

  • \(M_R\) is the number of rotations.

  • \(M_T\) is the number of T operations.

  • \(3*M_mathrm{Tof}\) is the number of Toffoli operations.

  • \(D_R\) is the number of layers containing at least one rotation. This can be smaller than the total number of non-Clifford layers since it excludes layers consisting only of T or Toffoli gates. Since we don’t compile the ‘layers’ explicitly, we set this to be the number of rotations.

Reference

__ne__

Check equality and either forward a NotImplemented or return the result negated.

__eq__

Method generated by attrs for class GateCounts.