-
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
Remove zero-probability states from Sampler's result #9248
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a43b0e2
Remove zero probability from Sampler's result
t-imamichi bd0c7d4
fix TestGrover
t-imamichi 539ba8e
add reno
t-imamichi dc9676c
Merge branch 'main' into sampler-zero-filter
t-imamichi 30a9311
fix a test
t-imamichi 3ec27fd
Merge branch 'main' into sampler-zero-filter
t-imamichi 1362a17
Merge branch 'main' into sampler-zero-filter
Cryoris 6ffe3bf
Merge branch 'main' into sampler-zero-filter
t-imamichi 8492b7b
Merge branch 'main' into sampler-zero-filter
t-imamichi 6c1ccf4
Merge branch 'main' into sampler-zero-filter
Cryoris 32a90c8
Merge branch 'main' into sampler-zero-filter
t-imamichi 9325e17
Merge branch 'main' into sampler-zero-filter
ikkoham 35dbd3b
round probabilities
ikkoham cac2cee
Merge branch 'main' into sampler-zero-filter
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
releasenotes/notes/update-sampler-zero-filter-8bf0d721af4fbd17.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
upgrade: | ||
- | | ||
Updated the reference implementation :meth:`~.Sampler.run` to return | ||
only states with non-zero probabilities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Now that 0 probabilities are not included, shouldn't this just show the "11" key here? That also seems to be what the error is about 🙂
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.
Ideal case should include "00", "01", and "10" with very small probabilities. The test on Linux passes but that on Mac fails. I'm investigating the difference.
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.
I cannot reproduce the CI failure locally on MacOS with Python 3.7 🤔
The values with which "00", "01" and "10" are included are about 1e-34 maybe we don't really need to check that this is recognized as non-zero? This seems a bit volatile to me... since this is about algorithm performance rather than the technicality which element is populated and from the sampler tests we know that the zero-probability states are removed, how about just checking if the values are correct in the Grover test? E.g. like
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.
I makes sense to me to filter out probabilities like this:
For the exact distribution: Remove probabilities satisfying$p_i \ll 1/|p| $ . The reasoning is that the sum of any set of $p_i$ s of this magnitude is negligible. On the other hand we may want to just remove what we think is in some sense a numerical artifact. This might not be easy to determine. For example
1e-34
is probably safe to remove. But the former at least has a reason behind the choice. You still have to decide what is much less than one. Maybe1e-10
For the distribution from samples, you should remove a probability if$p_i / n_\text{shots} \ll 1$ . This will make sampling efficient.
But you want to do something to remove small probabilities in both cases. The
dict
s could otherwise consume a lot of memory and be populated mostly with garbage.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.
I will use decimals of
Statevector.probabilities
to round the results.