qml.labs.resource_estimation.estimate_resources¶
- estimate_resources(obj, gate_set={'CNOT', 'Hadamard', 'S', 'T', 'Toffoli', 'X', 'Y', 'Z'}, config={'error_rx': 1e-09, 'error_ry': 1e-09, 'error_rz': 1e-09, 'precision_alias_sampling': 1e-09, 'precision_mps_prep': 1e-09, 'precision_qrom_state_prep': 1e-09, 'precision_qubit_unitary': 1e-09, 'precision_select_pauli_rot': 1e-09}, work_wires=0, tight_budget=False, single_qubit_rotation_error=None)[source]¶
Estimate the quantum resources required from a circuit or operation in terms of the gates provided in the gateset.
- Parameters:
obj (Union[ResourceOperator, Callable, Resources, List]) – The quantum circuit or operation to obtain resources from.
gate_set (Set, optional) – A set of names (strings) of the fundamental operations to track counts for throughout the quantum workflow.
config (Dict, optional) – A dictionary of additional parameters which sets default values when they are not specified on the operator.
single_qubit_rotation_error (Union[float, None]) – The acceptable error when decomposing single qubit rotations to T-gates using a Clifford + T approximation. This value takes preference over the values set in the
config
.
- Returns:
the quantum resources required to execute the circuit
- Return type:
- Raises:
TypeError – could not obtain resources for obj of type
type(obj)
Example
We can track the resources of a quantum workflow by passing the quantum function defining our workflow directly into this function.
import pennylane.labs.resource_estimation as plre def my_circuit(): for w in range(2): plre.ResourceHadamard(wires=w) plre.ResourceCNOT(wires=[0,1]) plre.ResourceRX(wires=0) plre.ResourceRY(wires=1) plre.ResourceQFT(num_wires=3, wires=[0, 1, 2]) return
Note that we are passing a python function NOT a
QNode
. The resources for this workflow are then obtained by:>>> res = plre.estimate_resources( ... my_circuit, ... gate_set = plre.DefaultGateSet, ... single_qubit_rotation_error = 1e-4, ... )() ... >>> 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}