Raise an error if gradient of QNode returning qml.sample()
is computed
#2556
Labels
enhancement ✨
New feature or request
qml.sample()
is computed
#2556
Feature details
Right now PennyLane allows computing the gradient of QNodes that returns
qml.sample()
. This is illustrated by the below code:This is unintuitive behaviour since the gradient of a sample doesn't really make any sense.
Instead of silently failing and producing nonsensical gradients, an error should be raised if the user tries to compute the gradient of a QNode that returns a sample. Ideally, the forward pass would still be supported.
Implementation
No response
How important would you say this feature is?
1: Not important. Would be nice to have.
Additional information
No response
The text was updated successfully, but these errors were encountered: