-
Notifications
You must be signed in to change notification settings - Fork 756
Open
Labels
enhancement ✨New feature or requestNew feature or request
Description
Expected behavior
Setting the seed kwarg at the device should result in a deterministic sampling execution.
Actual behavior
Doesn't get properly seeded.
Additional information
If you seed both at the MP and device level it works as expected,
import pennylane as qp
@qp.set_shots(10)
@qp.qnode(qp.device("default.qubit", seed=123, wires=1))
def circuit():
qp.H(0)
return qp.shadow_expval(qp.Z(0), seed=42) # SET HERE(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
(array(-1.2), np.float64(0.0))
Source code
import pennylane as qp
for i in range(10):
@qp.set_shots(10)
@qp.qnode(qp.device("default.qubit", wires=1, seed=42))
def circuit():
qp.H(0)
return qp.shadow_expval(qp.Z(0)), qp.expval(qp.Z(0))
print(circuit())Tracebacks
(array(-0.6), np.float64(-0.2))
(array(0.6), np.float64(-0.2))
(array(0.6), np.float64(-0.2))
(array(-0.3), np.float64(-0.2))
(array(-0.3), np.float64(-0.2))
(array(-0.6), np.float64(-0.2))
(array(-0.3), np.float64(-0.2))
(array(-0.3), np.float64(-0.2))
(array(-0.3), np.float64(-0.2))
(array(0.3), np.float64(-0.2))System information
PL v0.44Existing GitHub issues
- I have searched existing GitHub issues to make sure the issue does not already exist.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancement ✨New feature or requestNew feature or request