-
Notifications
You must be signed in to change notification settings - Fork 557
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
Improve operator support for new assert_equal
function: Group 1
#5644
Comments
assert_equal
functionassert_equal
function
assert_equal
functionassert_equal
function: Group 1
…tion: group 1 As suggested in [PennyLaneAI#5644], makes kernels _equals_operators, _equal_controlled _equal_pow, _equal_adjoint and _equal_exp return either True or a string explaining why two operators are not the same.
…tion: group 1 As suggested in [PennyLaneAI#5644], makes kernels _equals_operators, _equal_controlled _equal_pow, _equal_adjoint and _equal_exp return either True or a string explaining why two operators are not the same.
…tion: group 1 As suggested in [PennyLaneAI#5644], makes kernels _equals_operators, _equal_controlled _equal_pow, _equal_adjoint and _equal_exp return either True or a string explaining why two operators are not the same.
…tion: group 1 As suggested in [PennyLaneAI#5644], makes kernels _equals_operators, _equal_controlled _equal_pow, _equal_adjoint and _equal_exp return either True or a string explaining why two operators are not the same.
Hi @albi3ro and @trbromley, I’ve submitted PR #5780. Once the PR is merged, could you please assign this issue to me before closing it? Thank you! |
…tion: group 1 As suggested in [PennyLaneAI#5644], makes kernels _equals_operators, _equal_controlled _equal_pow, _equal_adjoint and _equal_exp return either True or a string explaining why two operators are not the same.
Thanks a lot @Tarun-Kumar07! Really excited to see some unitaryHACK contributions coming in 🧑💻 It looks like @EuGig has also opened a PR for this issue:
We like to encourage working together as much as possible if it works for both of you. Would it make sense for @Tarun-Kumar07 to take on #5648 and @EuGig to take on #5644? |
Sounds good to me!! |
Awesome, what do you think @Tarun-Kumar07? |
Hi @trbromley and @EuGig, I am open to collaboration. While working on #5644, I had to make some changes due to failing unit tests, which also addressed #5648. I attempted to separate the changes, but it seems they need to be in one PR. I have completed the changes for both issues and only waiting for the feedback. If you feel there are still some gaps, @EuGig, I would be happy to collaborate further to address them. |
Thanks @Tarun-Kumar07, that can work! So the proposal is:
If that's good for both of you, then I think it's a great idea. |
@trbromley Sounds good to me!! |
Context
PennyLane currently has a
qml.equal
function which can be used to check the equality of operators, measurements, and tapes. While this has been extremely useful in testing and validation, it can be difficult to figure out why two objects aren't equal.This is why we are currently have added the framework for an
assert_equal
function:pennylane/pennylane/ops/functions/equal.py
Line 179 in b6e9658
The framework for this function was added in PR #5634 , but the implementation still needs to be updated.
Implementation Details
Comparison currently relies on a
_equal
single dispatch function, with different "kernels" registered for different types of operators. Currently this function returnsTrue
orFalse
. We are changing it to returnTrue
, or a string that explains why the two operators are not equal. This change has already been made forBasisRotation
:pennylane/pennylane/ops/functions/equal.py
Line 605 in b6e9658
This task is to update
_equal
forOperator
classes: see_equal_operators
Controlled
classes: see_equal_controlled
Pow
classes: see_equal_pow
Adjoint
classes: see_equal_adjoint
Exp
classes: see_equal_exp
While more single dispatch kernels exist for
_equal
, they will be updated as part of separate tasks.After this PR, we should be able to do something like:
Use your best judgement as to the contents of the string and we will help refine the message if needed.
Additional Requirements
To fulfill this task, a PR should:
_equal
kernels for the above casestest_equal.py
. Existing tests like,test_adjoint_comparison
can be extended, or new tests can be written.The text was updated successfully, but these errors were encountered: