-
Notifications
You must be signed in to change notification settings - Fork 746
Open
Labels
bug 🐛Something isn't workingSomething isn't working
Description
Expected behavior
When using a quantum circuit with qml.Barrier, I would assume that the barrier would be interpreted as either identity or as some sort of compilation barrier. Or at least it should throw an error since the behaviour might not be well-defined (?).
Actual behavior
An error is thrown that leaves the user clueless of what the reason is.
Additional information
No response
Source code
import pennylane as qml
dev = qml.device("default.qubit")
@qml.qnode(dev)
def circuit():
qml.H(0)
qml.Barrier()
qml.H(0)
return qml.expval(qml.Z(0))
qml.estimator.estimate(circuit)()Tracebacks
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[4], line 12
9 qml.H(0)
10 return qml.expval(qml.Z(0))
---> 12 qml.estimator.estimate(circuit)()
File ~/efficient-multiscale-learning/.venv/lib/python3.11/site-packages/pennylane/estimator/estimate.py:318, in _resources_from_qfunc.<locals>.wrapper(*args, **kwargs)
316 wire_manager.algo_wires = num_algo_qubits
317 # Obtain resources in the gate_set
--> 318 compressed_res_ops_list = _ops_to_compressed_reps(q.queue)
319 gate_counts = defaultdict(int)
320 for cmp_rep_op in compressed_res_ops_list:
File ~/miniconda311/lib/python3.11/contextlib.py:81, in ContextDecorator.__call__.<locals>.inner(*args, **kwds)
78 @wraps(func)
79 def inner(*args, **kwds):
80 with self._recreate_cm():
---> 81 return func(*args, **kwds)
File ~/efficient-multiscale-learning/.venv/lib/python3.11/site-packages/pennylane/estimator/estimate.py:530, in _ops_to_compressed_reps(ops)
528 cmp_rep_ops.append(op.resource_rep_from_op())
529 elif isinstance(op, Operator):
--> 530 cmp_rep_ops.append(_map_to_resource_op(op).resource_rep_from_op())
532 return cmp_rep_ops
File ~/miniconda311/lib/python3.11/functools.py:909, in singledispatch.<locals>.wrapper(*args, **kw)
905 if not args:
906 raise TypeError(f'{funcname} requires at least '
907 '1 positional argument')
--> 909 return dispatch(args[0].__class__)(*args, **kw)
File ~/efficient-multiscale-learning/.venv/lib/python3.11/site-packages/pennylane/estimator/resource_mapping.py:74, in _map_to_resource_op(op)
71 if len(decomp) == 1:
72 return _map_to_resource_op(decomp[0])
---> 74 return re_ops.Prod(tuple(_map_to_resource_op(d_op) for d_op in decomp), wires=op.wires)
76 raise NotImplementedError(
77 "Operation doesn't have a resource equivalent and doesn't define a decomposition."
78 )
File ~/efficient-multiscale-learning/.venv/lib/python3.11/site-packages/pennylane/estimator/ops/op_math/symbolic.py:652, in Prod.__init__(self, res_ops, wires)
649 ops = []
650 counts = []
--> 652 ops, counts = zip(
653 *(item if isinstance(item, (list, tuple)) else (item, 1) for item in res_ops)
654 )
656 _dequeue(op_to_remove=ops)
657 self.queue()
ValueError: not enough values to unpack (expected 2, got 0)System information
Name: pennylane
Version: 0.44.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page:
Author:
License:
Location: /home/felix.herbort/efficient-multiscale-learning/.venv/lib/python3.11/site-packages
Platform info: Linux-6.1.0-39-amd64-x86_64-with-glibc2.36
Python version: 3.11.13
Numpy version: 2.3.4
Scipy version: 1.16.3
JAX version: 0.9.0
Installed devices:
- lightning.qubit (pennylane_lightning-0.44.0)
- default.clifford (pennylane-0.44.0)
- default.gaussian (pennylane-0.44.0)
- default.mixed (pennylane-0.44.0)
- default.qubit (pennylane-0.44.0)
- default.qutrit (pennylane-0.44.0)
- default.qutrit.mixed (pennylane-0.44.0)
- default.tensor (pennylane-0.44.0)
- null.qubit (pennylane-0.44.0)
- reference.qubit (pennylane-0.44.0)Existing GitHub issues
- I have searched existing GitHub issues to make sure the issue does not already exist.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug 🐛Something isn't workingSomething isn't working