-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
QNode
to not mutate original MCM config (#5850)
As name says. Mutating the config in place was causing unexpected results such as below. Now we create a copy of the original config before execution begins, which can be mutated as needed. ```python import pennylane as qml dev = qml.device("default.qubit") @qml.qnode(dev, postselect_mode="fill-shots") def f(x, mp): qml.RX(x, 0) qml.measure(0, postselect=1) return mp(qml.PauliZ(0)) ``` ```pycon >>> print(f(1.8, qml.sample, shots=10)) [-1. -1. -1. -1. -1. -1. -1. -1. -1. -1.] >>> print(f(1.8, qml.expval)) -0.9999999999999998 >>> print(f(1.8, qml.sample, shots=10)) [-1. -1. -1. -1. -1. -1.] ```
- Loading branch information
Showing
3 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters