-
Notifications
You must be signed in to change notification settings - Fork 630
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
Return every outcome with counts (those with 0
counts too)
#2864
Comments
0
counts too)
@antalszava I can update the qml.counts method for this fix, it doesn’t seem to me like the recent modifications change the task much. But since it seems like maybe other modifications to the ‘counts’ feature are being made simultaneously, I wanted to check if there is anyone I should coordinate with. Thanks, |
One other question: the issue description suggests updating the logic in the QubitDevice.sample object, but it seems like qml.sample calls the 'sample' function from measurements.py, not QubitDevice.sample Should the QubitDevice.sample method be updated to return 0 counts, or is it being phased out in favour of qml.counts and qml.sample? It seems like a confusing duplicity that qml.sample and dev.sample are different functions that live in different files and take different arguments. |
Hi @lillian542,
Yes, great catch there! We just changed the UI of counts to go from
The logic of determining the counts themselves is contained in Hope this helps, let us know if you have further questions! |
Hi @antalszava! Thanks so much, that's very helpful - I was getting a bit mixed up with how everything fit together, it makes a lot more sense now. |
Hi again! When updating the measurements.rst doc file to reflect changes, I noticed an example where the counts function is used along with other measurement functions. That is:
This is not currently working, either on my current working branch or the master branch. Instead of returning an outcome like the one shown in measurements.rst:
it returns a WireError. Should I flag this as a separate issue, or include a fix in the PR for this? Or does it just work differently now that counts is run as qml.counts() instead of qml.sample(counts=True)? |
Never mind, I now realize it was just an issue with the argument passed to PauliX in the example. |
EDIT: I'll move these questions to the pull request, they don't seem like they really belong here. I'm almost ready to submit a pull request, but I haven't run software testing and docs testing before, and I have a couple of questions:
|
Hi! I’ve created a pull request now, but its still currently a draft - I haven’t quite gotten it to pass the last core-and-interface-tests. Is it possible someone could take a look at help me understand what’s going on? More details on the PR. Once this is done, the PR should be ready for review. |
Hi @lillian542, yes, will go through the PR later today. 👍 Thanks for submitting! |
🎉 |
Feature details
The ability to compute the counts of outcomes from raw samples has recently been added to PennyLane (#2686 #2839).
The output of the new measurement is a dictionary where keys are the outcomes and the values are counts. Possible outcomes that were not observed do not appear in the dictionary.
We would to switch to listing all possible outcomes in the resulting dictionary.
Considering the following QNode evaluation:
We would like the output structure to be changed from
{'000': 531, '100': 469}
to become
{'000': 531, 001': 0, '010': 0, '011': 0, '100': 469, '101': 0, '110': 0 '111': 0}
.Note that in the above example, no observables or wires were passed to
qml.sample
. When providing an observable, then all possible eigenvalues should appear as keys in the dictionary, e.g.,Instead of
{1: 1000}
the output should be changed to{-1: 0, 1: 1000}
.Implementation
Potentially done using a
defaultdict
object. The implementation has to update the logic inQubitDevice
and in specific most likely theQubitDevice.sample
method and its capability to obtain counts.How important would you say this feature is?
1: Not important. Would be nice to have.
Additional information
No response
The text was updated successfully, but these errors were encountered: