Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix] Unary mid-circuit measurement expressions lack support (#5480)
### Before submitting Please complete the following checklist when submitting a PR: - [x] All new features must include a unit test. If you've fixed a bug or added code that should be tested, add a test to the test directory! - [x] All new functions and code must be clearly commented and documented. If you do make documentation changes, make sure that the docs build and render correctly by running `make docs`. - [x] Ensure that the test suite passes, by running `make test`. - [x] Add a new entry to the `doc/releases/changelog-dev.md` file, summarizing the change, and including a link back to the PR. - [x] The PennyLane source code conforms to [PEP8 standards](https://www.python.org/dev/peps/pep-0008/). We check all of our code against [Pylint](https://www.pylint.org/). To lint modified files, simply `pip install pylint`, and then run `pylint pennylane/path/to/file.py`. When all the above are checked, delete everything above the dashed line and fill in the pull request template. ------------------------------------------------------------------------------------------------------------ **Context:** @dwierichs reported the following bug ``` import pennylane as qml import numpy as np dev = qml.device("default.qubit", shots=100) # Shot-based device -> dynamic_one_shot transform will be used. @qml.qnode(dev) def node(x): [qml.RX(np.pi/2, w) for w in [0, 1]] mcm0 = qml.measure(0) mcm1 = qml.measure(1) # Not working return qml.expval(mcm0 * 2) return qml.expval(mcm0 + 1) return qml.expval(mcm0 & 3) node(0.4) ``` **Description of the Change:** `gather_mcm` uses the none-`use_as_is` branch if the measurement values branches are not 0 and 1. **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** Unary mid circuit measurement expressions [sc-60856] --------- Co-authored-by: Mudit Pandey <[email protected]>
- Loading branch information