-
Notifications
You must be signed in to change notification settings - Fork 575
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
Generalize qml.probs() to compute probabilities with respect to an eigenbasis #1692
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov Report
@@ Coverage Diff @@
## master #1692 +/- ##
=======================================
Coverage 99.22% 99.22%
=======================================
Files 207 207
Lines 15579 15587 +8
=======================================
+ Hits 15458 15466 +8
Misses 121 121
Continue to review full report at Codecov.
|
[ch7663] |
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.
Why are we limiting this to just qml.Hermitian
observables? Why not any kind of Observable?
Also, MeasurementProcess
uses obs
, but then some of the creation functions use op
. Since we can only pass in observables, and only one observable, maybe we should standardize the use of ob
across the file. Names do matter since the user does have to pass operation in as a keyword argument.
I think we should actually look into using multiple dispatch for these MeasurementProcess
factory methods,, but that would be outside the scope of this PR.
Also, a general comment on the formatting changes to files that aren't actually affected by a given PR. Might want to revert default_qubit
and _qubit_device
.
It might be worth asking @cvjjm for more details on the exact use case they were considering in the original issue :) |
I suppose every kind of observable that define diagonalizing_gates() can be supported. Even better, a list of jointly measurable observables could probably be supported as well without too much effort. |
... because then it should be possible to use the exact same pre-measurement rotation machinery that PL also uses for things like expval and var. |
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.
Just some minor wording changes, but after that, this PR seems to get the job done so I'll approve it.
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
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.
Glad to have this 😃
Context:
Previously qml.probs() was not able to accept an Hermitian observable, in order to give the probabilities in another basis than the computational one.
Description of the Change:
Now it is possible to give an optional Hermitian observable that will be used to rotate the circuit before measuring the probabilities. Then we receive the probabilities of the state in the Hermitian eigenbasis.
Related GitHub Issues:
This is a user requested feature, closes #1468