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
qml.Projector
compatibility with new default qubit
#4452
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov Report
@@ Coverage Diff @@
## master #4452 +/- ##
=======================================
Coverage 99.71% 99.71%
=======================================
Files 376 376
Lines 34130 34134 +4
=======================================
+ Hits 34034 34038 +4
Misses 96 96
|
…nylane into projector_pickle
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.
this looks great! I'm wondering in light of a recent PR from @albi3ro for similar problems with adjoint, should we just change the typing of Projectors altogether? I'm personally fine to implement __reduce__
as you've done here, but we should probably be consistent with type-overloading across PL.
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Changing the output type of While checking this, we found that the Cirq plugin translates the |
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.
fantastic!
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.
Thanks for figuring all these issues out 👍 🚀
* compatibility with DefaultQubit2 * update changelog * testing tests * extensive testing * more tests * Fix `__reduce__` docstring Co-authored-by: Matthew Silverman <matthews@xanadu.ai> * Fix test Co-authored-by: Matthew Silverman <matthews@xanadu.ai> * simplify typing * formatting * simplify measurement logic * serialize without * remove copy and extend serialization tests * remove redundant inheritance --------- Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
With the last release,
qml.Projector
lost its pickle-ability with the new dynamic type. This has affected some users (e.g. #4443) and makes it incompatible with the new default qubit multiprocessing. Testing the observable with the new device, I found a couple of additional points that had to be fixed for it to be fully compatible.I have written a
__reduce__
method forqml.Projector
that allows it to be pickled. I have done so in a way that the object can be serialized and loaded keeping all its original attributes (includingid
). I have also changed the branching conditions forqml.Projector
inmeasurements/expval.py
andmeasurements/var.py
as we had done originally for_device.py
.Fixes #4443
[sc-43218]