qml.estimator.estimate.estimate

estimate(workflow, gate_set=None, zeroed=0, any_state=0, tight_budget=False, config=None)[source]

Estimate the quantum resources required by a circuit or operator with respect to a given gateset.

Parameters:
  • workflow (Callable | ResourceOperator | Resources) – The quantum circuit or operator for which to estimate resources.

  • gate_set (set[str] | None) – A set of names (strings) of the fundamental operators to track counts for throughout the quantum workflow.

  • zeroed (int | None) – Number of zeroed state work wires. Default is 0.

  • any_state (int | None) – Number of work wires in an unknown state. Default is 0.

  • tight_budget (bool | None) – Determines whether extra zeroed state wires may be allocated when they exceed the available amount. The default is False.

  • config (ResourceConfig | None) – A ResourceConfig object which modifies default behaviour in the estimation pipeline.

Returns:

The estimated quantum resources required to execute the circuit.

Return type:

Resources | Callable[…, Resources]

Raises:

TypeError – could not obtain resources for workflow of type type(workflow)

Example

The resources of a quantum workflow can be estimated by passing the quantum function describing the workflow directly into this function.

import pennylane.estimator as qre

def my_circuit():
    for w in range(2):
        qre.Hadamard(wires=w)

    qre.CNOT(wires=[0,1])
    qre.RX(wires=0)
    qre.RY(wires=1)

    qre.QFT(num_wires=3, wires=[0, 1, 2])
    return

Note that a python function is passed here, not a QNode. The resources for this workflow are then obtained by:

>>> import pennylane.estimator as qre
>>> config = qre.ResourceConfig()
>>> config.set_single_qubit_rot_precision(1e-4)
>>> res = qre.estimate(
...     my_circuit,
...     gate_set = qre.DefaultGateSet,
...     config = config,
... )()
...
>>> print(res)
--- Resources: ---
Total qubits: 3
Total gates : 279
Qubit breakdown:
 clean qubits: 0, dirty qubits: 0, algorithmic qubits: 3
Gate breakdown:
 {'Hadamard': 5, 'CNOT': 10, 'T': 264}