-
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.
Fix transforms that error with non-commuting measurements (#5424)
**Context:** `tape.expand` will error out if the tape has any non-commuting measurements present. But multiple transforms that don't care about measurements at all use it to decompose to a target gate set. Even when `expand_measurements=False`, `tape.expand` requires measurements to be commuting, or composite observables. And this is a core behavior of `tape.expand` that people might rely on. It's not as much a bug as a problematic feature. AKA load-bearing bug. Fortunately, we now have `qml.devices.preprocess.decompose`, which is a transform that is capable of decomposing to a target gateset. While yes, this transform is in the `devices` module, so using it is introducing a cross-module dependency in a direction that we do not want, it gets the job done. I would call this a sign that we should potentially consider moving it into the `transforms` module and making it's import path more accessible. **Description of the Change:** Use `decompose` instead of `tape.expand` in a variety of transforms. **Benefits:** These transforms now allow non-commuting measurements through. **Possible Drawbacks:** We still have other transforms still relying on `tape.expand`. But we can investigate those another day. Introducing a cross-module dependency in a direction we don't want a dependency. This could be fixed by moving `decompose` to the transforms module, but that is a problem for another day. **Related GitHub Issues:** Fixes #5401 Fixes #5316 [sc-58086] [sc-59118] --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai> Co-authored-by: Astral Cai <astral.cai@xanadu.ai> Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com> Co-authored-by: David Wierichs <david.wierichs@xanadu.ai> Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
- Loading branch information
1 parent
7e51d2b
commit cfcef86
Showing
19 changed files
with
231 additions
and
59 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
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
Oops, something went wrong.