-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement transform for full single-qubit gate fusion #1458
Merged
glassnotes
merged 61 commits into
master
from
ch7105-implement-transform-for-full-single-qubit
Jul 20, 2021
Merged
Changes from 50 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
0406efc
Copy over some files from 1384.
8560c1d
Add optimization utils file.
68f9e79
Add updated qubit ops file.
09a3ae1
Update init file.
eba5f51
Streamline utils file.
5781743
Update operation.py.
7a21d41
Add arctan, and add JAX 64-bit support to test.
7118152
Remove as_rot_angles.
b156b70
Update docstrings.
0a9abe9
Merge branch 'master' into ch7104-implement-transforms-to-cancel-redu…
glassnotes c99f3cd
Merge branch 'ch7104-implement-transforms-to-cancel-redundant' of htt…
76947be
Shorten variable names for better readability.
2b04ec2
Update default values of compilation tags.
glassnotes 95a61a9
Update CHANGELOG.
glassnotes af55d17
Add new transforms to docs.
glassnotes 86f4f5e
Merge branch 'master' into ch7104-implement-transforms-to-cancel-redu…
glassnotes 2f78671
Apply suggestions from code review
glassnotes 0f20fa9
Add support for cancelling adjacent adjoint gates.
glassnotes c26d14b
Improve docstrings for compilation attributes. Add symmetric over con…
glassnotes 2ecb449
Adjust Toffoli test case.
glassnotes f7fb6c7
Convert utility functions to non-private.
glassnotes dd73732
Add tests for utility functions.
glassnotes a783181
Add optional parameters for rotation merging.
glassnotes 2b29cf0
Streamline angle fusion for 0 cases.
glassnotes 82688ac
Disable warning for too many return statements.
glassnotes be50d8d
Apply suggestions from code review
glassnotes d960e87
Add tests for optimization utils.
glassnotes 7ce969f
Merge branch 'ch7104-implement-transforms-to-cancel-redundant' of htt…
glassnotes 20198e7
Add transform for full single-qubit fusion.
glassnotes 16f8e8d
Add example to CHANGELOG.
glassnotes 622f4cd
Fix indentation in CHANGELOG.
glassnotes 33333d8
Merge branch 'ch7104-implement-transforms-to-cancel-redundant' into c…
glassnotes b81be2a
Fix grammar.
glassnotes cdc3326
Adjust docstring.
glassnotes cb02556
Update .github/CHANGELOG.md
glassnotes 2cf1062
Update .github/CHANGELOG.md
glassnotes 121ec6f
Add exception handling. Add missing gates to tests.
glassnotes 62c394b
Merge branch 'ch7105-implement-transform-for-full-single-qubit' of ht…
glassnotes 1f584f2
Update .github/CHANGELOG.md
josh146 06965cf
Apply suggestions from code review
glassnotes a262b14
Rename as_rot_angles to single_qubit_rot_angles.
glassnotes 2c30e6a
Clarify documentation and update single_qubit_rot_angles name.
glassnotes c867c42
Add option for gate exclusion.
glassnotes 5fbd0e4
Rename specify_ops to include_gates.
glassnotes 2f741fd
Remove spurious print statement.
glassnotes b472282
Apply suggestions from code review
glassnotes 056350e
Set rtol and clarify fusion is for two or more gates in a row.
glassnotes df6b181
Fix test.
glassnotes c39c36a
Update handling of tolerance.
glassnotes b282724
Merge branch 'ch7104-implement-transforms-to-cancel-redundant' into c…
glassnotes 4e748dd
Update pennylane/transforms/optimization/single_qubit_fusion.py
glassnotes 5c9b4db
Update pennylane/transforms/optimization/single_qubit_fusion.py
glassnotes ac052ee
Merge branch 'master' into ch7105-implement-transform-for-full-single…
josh146 7993658
Fix codefactor issues. Simplify some logic and add final test case fo…
glassnotes 6ce3f82
Merge branch 'ch7105-implement-transform-for-full-single-qubit' of ht…
glassnotes 449b343
Disable too-many-branches.
glassnotes 0fc444b
Merge branch 'master' into ch7105-implement-transform-for-full-single…
glassnotes ce19bdd
Update docstring. Add tests for single_qubit_rot_angles.
glassnotes fe64b63
Merge branch 'ch7105-implement-transform-for-full-single-qubit' of ht…
glassnotes f94ea21
Add missing tests to complete coverage.
glassnotes 142ab05
Merge branch 'master' into ch7105-implement-transform-for-full-single…
glassnotes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -539,6 +539,61 @@ def grad_method(self): | |
s_1]=[-1/2, 1, -\pi/2]` is assumed for every parameter. | ||
""" | ||
|
||
# Attributes for compilation transforms | ||
is_self_inverse = None | ||
"""bool or None: ``True`` if the operation is its own inverse. | ||
|
||
If ``None``, all instances of the given operation will be ignored during | ||
compilation transforms involving inverse cancellation. | ||
""" | ||
|
||
is_symmetric_over_all_wires = None | ||
"""bool or None: ``True`` if the operation is the same if you exchange the order | ||
of wires. | ||
|
||
For example, ``qml.CZ(wires=[0, 1])`` has the same effect as ``qml.CZ(wires=[1, | ||
0])`` due to symmetry of the operation. | ||
|
||
If ``None``, all instances of the operation will be ignored during | ||
compilation transforms that check for wire symmetry. | ||
""" | ||
|
||
is_symmetric_over_control_wires = None | ||
"""bool or None: ``True`` if the operation is the same if you exchange the order | ||
of all but the last wire. | ||
|
||
For example, ``qml.Toffoli(wires=[0, 1, 2])`` has the same effect as | ||
``qml.Toffoli(wires=[1, 0, 2])``, but neither are the same as | ||
``qml.Toffoli(wires=[0, 2, 1])``. | ||
|
||
If ``None``, all instances of the operation will be ignored during | ||
compilation transforms that check for control-wire symmetry. | ||
""" | ||
|
||
is_composable_rotation = None | ||
"""bool or None: ``True`` if composing multiple copies of the operation | ||
results in an addition (or alternative accumulation) of parameters. | ||
|
||
For example, ``qml.RZ`` is a composable rotation. Applying ``qml.RZ(0.1, | ||
wires=0)`` followed by ``qml.RZ(0.2, wires=0)`` is equivalent to performing | ||
a single rotation ``qml.RZ(0.3, wires=0)``. | ||
|
||
If set to ``None``, the operation will be ignored during compilation | ||
transforms that merge adjacent rotations. | ||
""" | ||
|
||
@property | ||
def single_qubit_rot_angles(self): | ||
"""The parameters required to implement a single-qubit gate as an | ||
equivalent ``Rot`` gate, up to a global phase. | ||
|
||
Returns: | ||
tuple[float, float, float]: A list of values :math:`[\phi, \theta, \omega]` | ||
such that :math:`RZ(\omega) RY(\theta) RZ(\phi)` is equivalent to the | ||
original operation. | ||
""" | ||
raise NotImplementedError | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is indeed covered in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
def get_parameter_shift(self, idx, shift=np.pi / 2): | ||
"""Multiplier and shift for the given parameter, based on its gradient recipe. | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌