pennylane
pennylane copied to clipboard
[BUG] Torch interface incompatibility with finite-shot mid-circuit measurements
Expected behavior
Able to execute the following QNode which includes:
- Use of torch interface
- Use of mid-circuit measurements
- Finite shots and a sample-based output
Actual behavior
Error when following QNode is executed.
Additional information
No response
Source code
import pennylane as qml
import torch
dev = qml.device("default.qubit", shots=10)
@qml.qnode(dev, interface="torch")
def f(x):
qml.RX(x, 0)
for i in range(5):
qml.Hadamard(0)
qml.measure(0)
return qml.sample(qml.PauliX(0))
x = torch.tensor(0.4)
f(x)
Tracebacks
AttributeError: 'Tensor' object has no attribute 'append'
System information
On the PL dev branch.
Existing GitHub issues
- [X] I have searched existing GitHub issues to make sure the issue does not already exist.
Related to this forum post.
CC @vincentmr.
Different errors, but also fails for jax and tensorflow.