-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR] Disallow MeasureOp
, PythonCallOp
and CustomCallOp
in gradients.
#204
[MLIR] Disallow MeasureOp
, PythonCallOp
and CustomCallOp
in gradients.
#204
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @erick-xanadu! I'm curious on the underlying issue - is it because measure
is returning an int
?
It is because the measurement is non-deterministic. If I'm wrong about this I can close this PR. I don't believe we currently handle the case for differentiating the following function in general. def f(x):
qml.RX(x, wires=0)
return measure(0) |
This is tricky, because you can use them with finite-diff if the overall function is deterministic. For example: def f(x):
qml.RY(x, wires=0)
m = measure(0)
cond(m)(lambda: qml.PauliX(0) and None)()
return qml.expval(qml.PauliZ(0)) But even a quantum function with def f(x):
qml.RY(x, wires=0)
return measure(0) that is post-processed into a deterministic output somehow could also be differentiable. Having said that, I could see for UX reasons that we might want to disallow those cases to prevent misuse on non-differentiable functions. But I'm not yet convinced that is the right move. |
9d7dbe3
to
1757cf5
Compare
MeasureOp
, PythonCallOp
and CustomCallOp
in gradients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @erick-xanadu, looks great!
…dients. (#204) **Context:** MeasureOp, PythonCallOp and CustomCallOp are allowed in gradients even though we don't support them yet. This leads to logic errors and bad UI/UX. **Description of the Change:** Verify that these operations are not reachable from the `grad` op. **Benefits:** Better UI/UX. [sc-42761]
Context: MeasureOp, PythonCallOp and CustomCallOp are allowed in gradients even though we don't support them yet. This leads to logic errors and bad UI/UX.
Description of the Change: Verify that these operations are not reachable from the
grad
op.Benefits: Better UI/UX.
[sc-42761]