-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transpose wire ordering for state results after transpile (#4793)
**Context:** The `transpile` transform changes the wires of everything after the necessary `SWAP` gates. Unfortunately, we have classes of measurements in PennyLane that are sensitive to the wire order but do not store the wire order on the measurement process. ``` dev = qml.device("default.qubit", wires = 4) coupling_map=[(1, 2), (0, 2), (1, 3)] @qml.transforms.transpile(coupling_map=coupling_map) @qml.qnode(dev) def circuit(): qml.Hadamard(wires = 0) qml.CNOT(wires = [0,1]) return qml.state() ``` **Description of the Change:** * The `transpile` transform now takes the device as a keyword argument * If the device is default mixed and the measurement is `StateMP`, we convert it to `DensityMatrixMP` * If the measurement process does not have wires and is not a `StateMP`, we update the measurement to give it the device wires 3) If any of the measurements are `StateMP`, the post-processing function transposes the state result **Benefits:** The output of the qnode will look the same with and without the transpile transform **Possible Drawbacks:** * Transposition of state result could potentially be classically expensive for larger systems **Related GitHub Issues:**
- Loading branch information
Showing
3 changed files
with
200 additions
and
9 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