-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Context:** Since we now often switch back and forth from operations to pauli rep's and back, we can end up with terms that are identities on no wires `qml.I()`. Individual expectation values of such a term are forbidden given may devices may not understand what to do with such a thing. `qml.expval(qml.I())` raises a `NotImplementedError`. But we still want to be able take expectation values of multi-term observables with constant offsets. **Description of the Change:** This PR just updates `qml.transforms.hamiltonian_expand` to handle multi-term observables with constant offsets. **Benefits:** `hamiltonian_expand` now works with multi-term observables with constant offsets. **Possible Drawbacks:** This PR does not also update `sum_expand`, as it seems like that transform first needs some organizational changes. **Related GitHub Issues:** [sc-55654] **Note:** Pylint was complaining about the complexity of the function so I broke it up a little bit. Makes more lines changed, but will probably be easier to read now. --------- Co-authored-by: Mudit Pandey <[email protected]>
- Loading branch information
Showing
7 changed files
with
186 additions
and
91 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
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
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