GateCounts#
qualtran.resource_counting.GateCounts
View source on GitHub
|
A data class of counts of the typical target gates in a compilation.
qualtran.resource_counting.GateCounts(
*,
t=attr_dict['t'].default,
toffoli=attr_dict['toffoli'].default,
cswap=attr_dict['cswap'].default,
and_bloq=attr_dict['and_bloq'].default,
clifford=attr_dict['clifford'].default,
rotation=attr_dict['rotation'].default,
measurement=attr_dict['measurement'].default
)
Specifically, this class holds counts for the number of TGate (and adjoint), Toffoli,
TwoBitCSwap, And, clifford bloqs, single qubit rotations, and measurements.
Attributes
Methods#
__add__
__add__(
other
)
__mul__
__mul__(
other
)
__rmul__
__rmul__(
other
)
asdict
asdict() -> Dict[str, int]
total_t_count
total_t_count(
ts_per_toffoli: int = 4,
ts_per_cswap: int = 4,
ts_per_and_bloq: int = 4,
ts_per_rotation: int = 11
) -> int
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
total_t_and_ccz_count(
ts_per_rotation: int = 11
) -> Dict[str, SymbolicInt]
total_toffoli_only
total_toffoli_only() -> int
The number of Toffoli-like gates, and raise an exception if there are Ts/rotations.
to_legacy_t_complexity
to_legacy_t_complexity(
ts_per_toffoli: int = 4,
ts_per_cswap: int = 7,
ts_per_and_bloq: int = 4,
cliffords_per_and_bloq: int = 9,
cliffords_per_cswap: int = 10
) -> 'TComplexity'
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
total_beverland_count() -> Dict[str, SymbolicInt]
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__
__ne__(
other
)
Check equality and either forward a NotImplemented or return the result negated.
__eq__
__eq__(
other
)
Method generated by attrs for class GateCounts.
View source on GitHub