QubitCount#

qualtran.resource_counting.QubitCount

A cost estimating the number of qubits required to implement a bloq.

Inherits From: CostKey

The number of qubits is bounded from below by the number of qubits implied by the signature. If a bloq has no callees, the size implied by the signature will be returned. Otherwise, this CostKey will try to compute the number of qubits by inspecting the decomposition.

In the decomposition, each (sub)bloq is considered to be executed sequentially. The “width” of the circuit (i.e. the number of qubits) at each sequence point is the number of qubits required by the subbloq (computed recursively) plus any “bystander” idling wires.

This is an estimate for the number of qubits required by an algorithm. Specifically:

  • Bloqs are assumed to be executed sequentially, minimizing the number of qubits potentially at the expense of greater circuit depth or execution time.

  • We do not consider “tetris-ing” subbloqs. In a decomposition, each subbloq is assumed to be using all of its qubits for the duration of its execution. This could potentially overestimate the total number of qubits.

This Min-Max style estimate can provide a good balance between accuracy and scalability of the accounting. To fully account for each qubit and manage space-vs-time trade-offs, you must comprehensively decompose your algorithm to a cirq.Circuit of basic gates and use a cirq.QubitManager to manage trade-offs. This may be computationally expensive for large algorithms.

Methods#

compute

View source

Compute an estimate of the number of qubits used by bloq.

See the class docstring for more information.

zero

View source

Zero cost is zero qubits.

__ne__

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

__eq__

Method generated by attrs for class QubitCount.