-
Notifications
You must be signed in to change notification settings - Fork 33
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
Use SamplerV2 and EstimatorV2 in tests #506
Comments
Actually, since |
I'd like to understand this issue better. Are there some examples you might recommend? |
We have a class called
|
In a And, admittedly, this is kind of a roundabout way of re-inventing the v1 interface -- but at least with the improved register access ergonomics of the v2 interface. |
Thanks for all of the details. It seems to me that The issue is that |
Thanks -- yeah, I agree that having our own data structure will be better than abusing SamplerV2 in the way I suggest. Actually, rather than use it as an intermediate, I expect we will want to be able to consume either (exact probabilities or samples) directly. The reason is that if we actually have samples to work with, then we should just use them as such so we can perform bootstrapping throughout the entire calculation (#257). |
* Use Aer's SamplerV2 instead of SamplerV1 Addresses part of #506 * `qiskit_aer.primitives.SamplerV2` does not support mid-circuit measurements so we use runtime `SamplerV2` with `AerSimulator` as the backend instead
* Migrate to `EstimatorV2` in tests Partially addresses #506. * black * Replace `observables` with `observables_nophase` The previous code passed `observables_nophase` to the cutting code, so it wasn't even testing the phases through the workflow. The correct way to handle such observables with nontrivial phase is to use the utility introduced in #587.
This change is motivated by the following warning: > DeprecationWarning: The class ``qiskit.primitives.base.base_sampler.BaseSampler`` > is deprecated as of qiskit 1.2. It will be removed no earlier > than 3 months after the release date. The `BaseSampler` class is > a type alias for the `BaseSamplerV1` interface that has been > deprecated in favor of explicitly versioned interface classes. > It is recommended to migrate all implementations to use > `BaseSamplerV2`. However, for implementations incompatible with > `BaseSamplerV2`, `BaseSampler` can be replaced with the explicitly > versioned `BaseSamplerV1` class. Related to #551 and #506.
This change is motivated by the following warning: > DeprecationWarning: The class ``qiskit.primitives.base.base_sampler.BaseSampler`` > is deprecated as of qiskit 1.2. It will be removed no earlier > than 3 months after the release date. The `BaseSampler` class is > a type alias for the `BaseSamplerV1` interface that has been > deprecated in favor of explicitly versioned interface classes. > It is recommended to migrate all implementations to use > `BaseSamplerV2`. However, for implementations incompatible with > `BaseSamplerV2`, `BaseSampler` can be replaced with the explicitly > versioned `BaseSamplerV1` class. Related to #551 and #506.
This change is motivated by the following warning: > DeprecationWarning: The class ``qiskit.primitives.base.base_sampler.BaseSampler`` > is deprecated as of qiskit 1.2. It will be removed no earlier > than 3 months after the release date. The `BaseSampler` class is > a type alias for the `BaseSamplerV1` interface that has been > deprecated in favor of explicitly versioned interface classes. > It is recommended to migrate all implementations to use > `BaseSamplerV2`. However, for implementations incompatible with > `BaseSamplerV2`, `BaseSampler` can be replaced with the explicitly > versioned `BaseSamplerV1` class. Related to #551 and #506. (cherry picked from commit a9bfc91)
This change is motivated by the following warning: > DeprecationWarning: The class ``qiskit.primitives.base.base_sampler.BaseSampler`` > is deprecated as of qiskit 1.2. It will be removed no earlier > than 3 months after the release date. The `BaseSampler` class is > a type alias for the `BaseSamplerV1` interface that has been > deprecated in favor of explicitly versioned interface classes. > It is recommended to migrate all implementations to use > `BaseSamplerV2`. However, for implementations incompatible with > `BaseSamplerV2`, `BaseSampler` can be replaced with the explicitly > versioned `BaseSamplerV1` class. Related to #551 and #506. (cherry picked from commit a9bfc91) Co-authored-by: Jim Garrison <garrison@ibm.com>
Eventually -- once support is added for
SamplerV2
(#488) and once Qiskit Aer supportsSamplerV2
andEstimatorV2
(Qiskit/qiskit-aer#2078) -- we should update the tests to use the v2 versions of the primitives.At the moment, I expect the migration to
EstimatorV2
to be relatively easy.SamplerV2
, however, is going to be a bit more involved.ExactSampler
returns exact probabilities, butSamplerV2
has moved away from probabilities and instead provides memory-based access to each shot outcome. So, the idea of an "exact sampler" is incompatible with the v2 sampler interface. Thus, we will probably stick withExactSampler
using the V1 interface for as long as we can. Once the V1 sampler interface is deprecated, we will be forced to upgrade, and this might mean we are no longer able to use the Sampler interface for the exact tests from this point forward. This is probably not a big deal, but it will be a minor inconvenience for us. Still, the v2 sampler is unambiguously a step forward, so I eagerly await the day when we can use it exclusively.The text was updated successfully, but these errors were encountered: