-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Unnecessary zero-probability states returned by Sampler, with different behaviour to Aer Sampler #9178
Comments
Thank you for your report. Aer passes bitstrings as integer to QuasiDistribution. So, the result looses the information of number of qubits. It might be good to remove results with zero probability for the reference implementation of Sampler though we don't guarantee the behavior. It may be a good first issue. |
Couldn't the |
Yes, it might be good to remove bits with 0 prob at |
Also Terra's Sampler should use |
This would be nice to fix. |
These PRs fix this issue |
Environment
What is happening?
Sampler
returns a dictionary with every possible state, even if some states have a probability 0 of being sampled. As the number of qubits is increased, the size of this dictionary will scale exponentially.Sampler
, which does not return states with probability 0. Importantly, since the number of qubits is not saved, this results in a faulty conversion to binary strings in qiskit_aer using thebinary_probabilities()
method. This is probably because the length of the binary strings is calculated based on the number of returned states instead of the number of qubits, which in Aer is a subset of all possible states.How can we reproduce the issue?
TERRA RESULTS:
{0: 0.5, 1: 0.5, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0, 6: 0.0, 7: 0.0, 8: 0.0, 9: 0.0, 10: 0.0, 11: 0.0, 12: 0.0, 13: 0.0, 14: 0.0, 15: 0.0}
{'0000': 0.5, '0001': 0.5, '0010': 0.0, '0011': 0.0, '0100': 0.0, '0101': 0.0, '0110': 0.0, '0111': 0.0, '1000': 0.0, '1001': 0.0, '1010': 0.0, '1011': 0.0, '1100': 0.0, '1101': 0.0, '1110': 0.0, '1111': 0.0}
AER RESULTS:
{1: 0.54, 0: 0.46}
{'1': 0.54, '0': 0.46}
What should happen?
We should see only the non-zero probability states in Terra, and a correct conversion to binary in Aer (i.e. matches the number of qubits):
TERRA RESULTS:
{0: 0.5, 1: 0.5}
{'0000': 0.5, '0001': 0.5}
AER RESULTS:
{1: 0.54, 0: 0.46}
{'0001': 0.54, '0000': 0.46}
Any suggestions?
"statevector"
method in Aer doesn't return zero probability states, the same steps could be applied to theStatevector
in Terra (which is called by theSampler
).SamplerResult
, such that Aer can properly do the conversion to binary probabilities.The text was updated successfully, but these errors were encountered: