You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚠️ This issue is part of an internal assignment and not meant for external contributors.
Context
We would like to add a transform to PennyLane that combines all qml.GlobalPhase gates in a circuit into a single one applied at the end. This can be useful for circuits that include a lot of qml.GlobalPhase gates, which can be introduced directly during circuit creation, decompositions that include qml.GlobalPhase gates, etc.
Implementation Details
This task is to add a new transform called combine_global_phases. This transform should be added to the pennylane/transforms folder in a new file called combine_global_phases.py.
This transform should:
Find all instances of qml.GlobalPhase in a QuantumScript, regardless of the wires that it is applied to
Sum the phase for each qml.GlobalPhase gate
Create a new QuantumScript that includes all the operations and measurements other than qml.GlobalPhase of the original QuantumScript
Apply a qml.GlobalPhase as the last operation in the new QuantumScript with the phase being equal to the sum computed earlier. Wires do not need to be specified for this qml.GlobalPhase
Include a docstring for the new combine_global_phases transform with details about what the transform does, arguments, return values, and a code example that showcases the transform
Include a changelog entry at doc/releases/changelog-dev.md. Make sure to include your name in the list of contributors at the bottom!
Add tests to a new file tests/transforms/test_combine_global_phases.py. The tests should include an adequate suite of both unit and integration tests.
Pass all existing tests including black and pylint checks
The text was updated successfully, but these errors were encountered:
**Description of the Change:**
I implemented a `qml.transform.combine_global_phases` transform to
combine all `qml.GlobalPhase` gates in a circuit into a single
`qml.GlobalPhase` operation (applied at the end of the new circuit
without specifying any wire) with the phase equal to the total algebraic
sum of each original phase.
**Benefits:**
This transform can be useful for circuits that include a lot of
`qml.GlobalPhase` gates, which can be introduced directly during circuit
creation, decompositions that include `qml.GlobalPhase` gates, etc.
**Related GitHub Issues:** #6644
---------
Co-authored-by: Astral Cai <[email protected]>
Co-authored-by: Christina Lee <[email protected]>
Co-authored-by: Mudit Pandey <[email protected]>
Important Note
Context
We would like to add a transform to PennyLane that combines all
qml.GlobalPhase
gates in a circuit into a single one applied at the end. This can be useful for circuits that include a lot ofqml.GlobalPhase
gates, which can be introduced directly during circuit creation, decompositions that includeqml.GlobalPhase
gates, etc.Implementation Details
This task is to add a new transform called combine_global_phases. This transform should be added to the pennylane/transforms folder in a new file called
combine_global_phases.py
.This transform should:
qml.GlobalPhase
in aQuantumScript
, regardless of the wires that it is applied toqml.GlobalPhase
gateQuantumScript
that includes all the operations and measurements other thanqml.GlobalPhase
of the originalQuantumScript
qml.GlobalPhase
as the last operation in the newQuantumScript
with the phase being equal to the sum computed earlier. Wires do not need to be specified for thisqml.GlobalPhase
Relevant functions include:
qml.GlobalPhase
qml.transforms.core.transform
Additional Requirements
A completed PR would:
combine_global_phases
transform with details about what the transform does, arguments, return values, and a code example that showcases the transformdoc/releases/changelog-dev.md
. Make sure to include your name in the list of contributors at the bottom!tests/transforms/test_combine_global_phases.py
. The tests should include an adequate suite of both unit and integration tests.The text was updated successfully, but these errors were encountered: