-
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 a validation check of circuits for BaseSampler
(follow-up of #8678)
#8708
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
195aefd
relax a check of measurements for Sampler
t-imamichi 3fc20ae
Merge branch 'main' into followup-8678
t-imamichi 1898e79
Merge branch 'main' into followup-8678
t-imamichi ebcf87b
Merge branch 'main' into followup-8678
t-imamichi 71ee01a
fix a test
t-imamichi be3f4e3
Merge branch 'main' into followup-8678
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
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: 2 additions & 3 deletions
5
releasenotes/notes/add-sampler-error-check-38426fb186db44d4.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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
upgrade: | ||
- | | ||
Added some error checks to :meth:`~qiskit.primitives.BaseSampler.run`. | ||
It raises an error if there is no classical bit or some classical bits | ||
are not used for measurements. | ||
Added a validation check to :meth:`~qiskit.primitives.BaseSampler.run`. | ||
It raises an error if there is no classical bit. | ||
|
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.
This looks like it is still going to raise if the number of clbits is not equal to the number of final measurements. That is to say that if I wrote to all my bits via mid-circuit measurements then this would be triggered.
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 is part of the reference implementation based on
quantum_info.Statevector
. It requires final measurements.Statevector
does not support mid-circuit measurements.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 updated the title of this PR to mention
BaseSampler
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.
But then you are blocking real-world use cases for a simulation method that does not scale. Does not seem like a fruitful direction to me.
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.
The reference implementation was designed to be as simple as possible. Runtime primitives and Aer primitives are more appropriate for scaling, e.g., Qiskit/qiskit-aer#1531
This is similar to the relationship of
BasicAer
andAer
simulator. The reference implementation of primitives corresponds toBasicAer
and Aer primitives corresponds toAer
simulator.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.
That is another way to think about it; Just overload all in Runtime. In some sense that is what would probably need to be done because a state vector simulator is quite far removed from a real hardware sampling routine
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.
There is a PR #8668 working on backend-based Sampler. It is closer to real hardware sampling. Once it's merged, we can discuss whether we need the reference implementation.
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 check is only part of the reference implementation of
Sampler
and not part ofBaseSampler
. So, other Sampler implementations does use this check. Other implementations are supposed to inherit onlyBaseSampler
.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.
The reference implementation
Sampler
needs this check. So, I have to put it inBaseSampler
(abstract class) orSampler
(reference implementation). I moved it fromSampler
toBaseSampler
in #8668. I want to revert it in this PR. If this PR is not merged, the check stays inBaseSampler
and raises an error for all implementations not only the reference impl but alsoqiskit-ibm-runtime
.