-
Notifications
You must be signed in to change notification settings - Fork 706
Open
Labels
enhancement ✨New feature or requestNew feature or request
Description
Feature details
The error message raised by estimate should explain why the error happened and instruct the user what they need to change to get something running.
Implementation
The error raised should be similar to what the decomposition transform says when the user supplies a gate set that cannot be targeted.
How important would you say this feature is?
2: Somewhat important. Needed this quarter.
Additional information
import pennylane as qml
import pennylane.estimator as qre
def circuit(n):
qre.Hadamard()
qre.BasisRotation(n)
mrx = qre.MultiRZ(2)
qre.Controlled(mrx, num_ctrl_wires=1, num_zero_ctrl=1)
qre.PhaseShift()
return
print(qml.estimator.estimate(circuit, gate_set={'RZ', 'CNOT'})(3))---------------------------------------------------------------------------
ResourcesUndefinedError Traceback (most recent call last)
Cell In[10], [line 12](vscode-notebook-cell:?execution_count=10&line=12)
9 qre.PhaseShift()
10 return
---> [12](vscode-notebook-cell:?execution_count=10&line=12) print(qml.estimator.estimate(circuit, gate_set={'RZ', 'CNOT'})(3))
File python3.13/site-packages/pennylane/estimator/estimate.py:314, in _resources_from_qfunc.<locals>.wrapper(*args, **kwargs)
312 gate_counts = defaultdict(int)
313 for cmp_rep_op in compressed_res_ops_list:
--> [314](python3.13/site-packages/pennylane/estimator/estimate.py:314) _update_counts_from_compressed_res_op(
315 cmp_rep_op, gate_counts, wire_manager=wire_manager, gate_set=gate_set, config=config
316 )
317 return Resources(
318 zeroed_wires=wire_manager.zeroed,
319 any_state_wires=wire_manager.any_state,
320 algo_wires=wire_manager.algo_wires,
321 gate_types=gate_counts,
322 )
File python3.13/site-packages/pennylane/estimator/estimate.py:437, in _update_counts_from_compressed_res_op(comp_res_op, gate_counts_dict, wire_manager, gate_set, scalar, config)
435 params = {key: value for key, value in comp_res_op.params.items() if value is not None}
436 filtered_kwargs = {key: value for key, value in kwargs.items() if key not in params}
--> [437](python3.13/site-packages/pennylane/estimator/estimate.py:437) resource_decomp = decomp_func(**params, **filtered_kwargs)
438 qubit_alloc_sum = _sum_allocated_wires(resource_decomp)
440 for action in resource_decomp:
File python3.13/site-packages/pennylane/estimator/ops/qubit/non_parametric_ops.py:63, in Hadamard.resource_decomp(cls)
51 @classmethod
52 def resource_decomp(cls) -> list[GateCount]:
53 r"""Returns a list representing the resources of the operator. Each object represents a quantum gate
54 and the number of times it occurs in the decomposition.
55
(...) 61 ResourcesUndefinedError: This gate is fundamental, no further decomposition defined.
62 """
---> [63](python3.13/site-packages/pennylane/estimator/ops/qubit/non_parametric_ops.py:63) raise ResourcesUndefinedError
ResourcesUndefinedError:
Metadata
Metadata
Assignees
Labels
enhancement ✨New feature or requestNew feature or request