-
Notifications
You must be signed in to change notification settings - Fork 547
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
Make CommutingEvolution
a SymbolicOp
#5682
base: master
Are you sure you want to change the base?
Conversation
Hello. You may have forgotten to update the changelog!
|
|
||
.. math:: O = O_1 O_2 \dots O_n. | ||
def matrix(self, wire_order=None) -> TensorLike: | ||
"""Raise a MatrixUndefinedError for now to force decomposition on DefaultQubit.""" |
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.
Potentially instead we can treat this like GroverOperator
and QFT
and manually say "decompose CommutingEvolution".
def _matrix(scalar, mat): | ||
return qml.math.expm(-1j * scalar * mat) |
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.
Potentially we could make _matrix
not an abstractmethod
? Then we woudn't need to define this.
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.
Done.
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.
Actually, do we want to do the following, @albi3ro ?
- Keep this
_matrix
method, removing the need for a custommatrix
method. - Thus, remove
matrix
- Remove
has_matrix
, becauseScalarSymbolicOp
already sets it toself.base.has_matrix
, and_matrix
is all that is needed to go from the Hamitlonian matrix to theCommutingEvolution
matrix. - Add a logic for
apply_operation
forCommutingEvolution
like forGroverOperator
etc
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5682 +/- ##
==========================================
- Coverage 99.68% 99.67% -0.01%
==========================================
Files 415 415
Lines 38886 38602 -284
==========================================
- Hits 38762 38477 -285
- Misses 124 125 +1 ☔ View full report in Codecov by Sentry. |
Context:
CommutingEvolution
has the structure of aScalarSymbolicOp
, so we make it one.Description of the Change:
Change base class of
CommutingEvolution
and adapt other attributes of the class to this change.In addition, a dispatch branch of
qml.equal
for allScalarSymbolicOp
s is introduced.Benefits:
Code quality
Possible Drawbacks:
Related GitHub Issues: