Hi Pennylane Team,
While working to solve the Secrets in Spacetime Challenge, I found some interesting behavior for measurement functions like expval() and counts() in Version 0.38.0. I was playing around with some observables and found a solution that worked on my machine (which had Version 0.36.0 installed at the time), but failed on the challenge submission. When I updated to the latest version I saw it failing on my machine as well.
This would be a minimal reproductible example of the observable I was trying to use:
import pennylane as qml
import pennylane.numpy as np
dev = qml.device("default.qubit", wires=2, shots=4)
@qml.qnode(dev)
def circuit(x):
qml.RX(x, wires=0)
qml.Hadamard(wires=1)
qml.CNOT(wires=[0, 1])
return qml.counts(qml.prod(qml.RX(x,0),qml.RZ(x,0))@qml.prod(qml.RX(x,1),qml.RZ(x,1)))
circuit(0.5)
The full error message is as follows:
pennylane.DeviceError: Measurement CountsMP(RX(0.5, wires=[0]) @ RZ(0.5, wires=[0]) @ RX(0.5, wires=[1]) @ RZ(0.5, wires=[1]), all_outcomes=False) not accepted with finite shots on default.qubit
I was doing some more testing and the lightning.qubit device seems to work on Version 0.38.0.
I’ll look into the implementation of the preprocess.py script to better understand the latest changes, but wanted to let you guys know.
I appreciate any thoughts.
Thanks!
Packages info:
Name: PennyLane
Version: 0.38.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: https://github.com/PennyLaneAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /home/fgranda/.local/lib/python3.10/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing-extensions
Required-by: PennyLane_Lightning
Platform info: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python version: 3.10.12
Numpy version: 1.26.4
Scipy version: 1.13.1
Installed devices:
- default.clifford (PennyLane-0.38.0)
- default.gaussian (PennyLane-0.38.0)
- default.mixed (PennyLane-0.38.0)
- default.qubit (PennyLane-0.38.0)
- default.qubit.autograd (PennyLane-0.38.0)
- default.qubit.jax (PennyLane-0.38.0)
- default.qubit.legacy (PennyLane-0.38.0)
- default.qubit.tf (PennyLane-0.38.0)
- default.qubit.torch (PennyLane-0.38.0)
- default.qutrit (PennyLane-0.38.0)
- default.qutrit.mixed (PennyLane-0.38.0)
- default.tensor (PennyLane-0.38.0)
- null.qubit (PennyLane-0.38.0)
- lightning.qubit (PennyLane_Lightning-0.38.0)