You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
glassnoteson Sep 30, 2024 • @dime10@josh146 I'm running into an issue here. I'd like to measure this wire and apply an operation based on the outcome, but I am getting a ValueError: Quantum measurements are not allowed. I'm using PL 0.38 and Catalyst 0.8.1.
To replicate, check out the branch and run python shors_algorithm.py 15.
I've included the stack trace in case it's helpful. I would post a bug report, but I haven't been able to make a minimal example yet. I suspect it has to do with nesting. This call is in a function called from a for loop within a function that is also called in a for loop, within a QNode, within the top-level qjitted function. As I reread that explanation, it sounds pretty ridiculous 😆
File "/home/olivia/.venv/shortalyst/lib/python3.12/site-packages/catalyst/autograph/ag_primitives.py", line 579, in converted_call
return ag_converted_call(fn, args, kwargs, caller_fn_scope, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/olivia/.venv/shortalyst/lib/python3.12/site-packages/malt/impl/api.py", line 319, in converted_call
return _call_unconverted(f, args, kwargs, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/olivia/.venv/shortalyst/lib/python3.12/site-packages/malt/impl/api.py", line 399, in _call_unconverted
return f(*args)
^^^^^^^^
File "/home/olivia/.venv/shortalyst/lib/python3.12/site-packages/catalyst/api_extensions/quantum_operators.py", line 407, in __call__
tracing_artifacts = self.trace_body(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/olivia/.venv/shortalyst/lib/python3.12/site-packages/catalyst/api_extensions/quantum_operators.py", line 439, in trace_body
_check_no_measurements(quantum_tape)
File "/home/olivia/.venv/shortalyst/lib/python3.12/site-packages/catalyst/api_extensions/quantum_operators.py", line 725, in _check_no_measurements
raise ValueError(msg)
ValueError: Quantum measurements are not allowed
josh146on Sep 30, 2024
🤔 It seems that this logic is called to verify that MCMs are not placed inside adjoint() regions -- I take it you are not within an adjoint region at this point in the code?
Side note though @dime10, we should update this error message to be more actionable lol.
The text was updated successfully, but these errors were encountered:
)
**Context:**
Improve the error message when using measure within an `adjoin()`
region.
**Example**
```python
import pennylane as qml
from pennylane import qjit
from catalyst import measure
dev = qml.device("lightning.qubit", wires=1)
@qjit
@qml.qnode(dev)
def circuit():
def foo():
measure(wires=0)
qml.adjoint(foo)()
return qml.expval(qml.PauliZ(0))
print(circuit())
```
**Description of the Change:**
Write and insert an error message `"Measurements are not invertible and
cannot be used within an adjoint() region."`
**Related GitHub Issues:**
#1188
---------
Co-authored-by: David Ittah <[email protected]>
The error message should be more actionable, telling the user that they cannot use
adjoint
on ameasure
operation.https://github.com/QSAR-UBC/shortalyst-dev/pull/7#discussion_r1782000436, excerpt below:
glassnotes on Sep 30, 2024 •
@dime10 @josh146 I'm running into an issue here. I'd like to measure this wire and apply an operation based on the outcome, but I am getting a ValueError: Quantum measurements are not allowed. I'm using PL 0.38 and Catalyst 0.8.1.
To replicate, check out the branch and run python shors_algorithm.py 15.
I've included the stack trace in case it's helpful. I would post a bug report, but I haven't been able to make a minimal example yet. I suspect it has to do with nesting. This call is in a function called from a for loop within a function that is also called in a for loop, within a QNode, within the top-level qjitted function. As I reread that explanation, it sounds pretty ridiculous 😆
josh146 on Sep 30, 2024
🤔 It seems that this logic is called to verify that MCMs are not placed inside adjoint() regions -- I take it you are not within an adjoint region at this point in the code?
Side note though @dime10, we should update this error message to be more actionable lol.
The text was updated successfully, but these errors were encountered: