BloqCount#

qualtran.resource_counting.BloqCount

A cost which is the count of a specific set of bloqs forming a gateset.

Inherits From: CostKey

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.

gateset_bloqs

A sequence of bloqs which we will count. Bloqs are counted according to their equality operator.

gateset_name

A string name of the gateset. Used for display and debugging purposes.

gateset_bloqs

 

gateset_name

 

Methods#

for_gateset

View source

Helper constructor to configure this cost for some common gatesets.

Args

gateset_name

One of ‘t’, ‘t+tof’, ‘t+tof+cswap’. This will construct a BloqCount cost with the indicated gates as the gateset_bloqs. In all cases, both TGate and its adjoint are included.

for_call_graph_leaf_bloqs

View source

Helper constructor to configure this cost for ‘leaf’ bloqs in a given call graph.

Args

g

The call graph. Its leaves will be used for gateset_bloqs. This call graph can be generated from Bloq.call_graph()

compute

View source

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

bloq

The bloq to compute the cost of.

get_callee_cost

A 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

View source

The value corresponding to zero cost.

__ne__

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

__eq__

Method generated by attrs for class BloqCount.