BloqCount#
qualtran.resource_counting.BloqCount
View source on GitHub
|
A cost which is the count of a specific set of bloqs forming a gateset.
Inherits From: CostKey
qualtran.resource_counting.BloqCount(
gateset_bloqs, gateset_name
)
Often, we wish to know the number of specific gates in our algorithm. This is a generic CostKey that can count any gate (bloq) of interest.
The cost value type for this cost is a mapping from bloq to its count.
Args
gateset_bloqsA sequence of bloqs which we will count. Bloqs are counted according to their equality operator.
gateset_nameA string name of the gateset. Used for display and debugging purposes.
Attributes
Methods#
for_gateset
@classmethodfor_gateset( gateset_name: str )
Helper constructor to configure this cost for some common gatesets.
Args
gateset_nameOne of ‘t’, ‘t+tof’, ‘t+tof+cswap’. This will construct a
BloqCountcost with the indicated gates as thegateset_bloqs. In all cases, both TGate and its adjoint are included.
for_call_graph_leaf_bloqs
@classmethodfor_call_graph_leaf_bloqs( g: nx.DiGraph )
Helper constructor to configure this cost for ‘leaf’ bloqs in a given call graph.
Args
gThe call graph. Its leaves will be used for
gateset_bloqs. This call graph can be generated fromBloq.call_graph()
compute
compute(
bloq: 'Bloq', get_callee_cost: Callable[['Bloq'], BloqCountDict]
) -> BloqCountDict
Compute this type of cost.
When implementing a new CostKey, this method must be overridden.
Users should not call this method directly. Instead: use the qualtran.resource_counting
functions like get_cost_value, get_cost_cache, or query_costs. These provide
caching, logging, generalizers, and support for static costs.
For recursive computations, use the provided callable to recurse.
Args
bloqThe bloq to compute the cost of.
get_callee_costA qualtran-provided function for computing costs for “callees” of the bloq; i.e. bloqs in the decomposition. Use this function to accurately cache intermediate cost values and respect bloqs’ static costs.
Returns
zero
zero() -> BloqCountDict
The value corresponding to zero cost.
__ne__
__ne__(
other
)
Check equality and either forward a NotImplemented or return the result negated.
__eq__
__eq__(
other
)
Method generated by attrs for class BloqCount.
View source on GitHub