-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fix init of EstimatorV2 and SamplerV2 #2120
Conversation
qiskit_aer/primitives/sampler_v2.py
Outdated
@@ -98,6 +98,12 @@ def __init__( | |||
self._seed = seed | |||
|
|||
self._options = Options(**options) if options else Options() | |||
if "method" not in self.options.backend_options: | |||
method = ( | |||
"density_matrix" if "noise_model" in self.options.backend_options else "automatic" |
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.
does this mean that noise simulation always use "density_matrix" in sampler?
qiskit_aer/primitives/sampler_v2.py
Outdated
"density_matrix" if "noise_model" in self.options.backend_options else "automatic" | ||
) | ||
ops = dict(method=method) | ||
self.options.backend_options.update(ops) |
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.
self.options.backend_options.update({method: method})
may be simpler.
if "method" not in self.options.backend_options: | ||
method = ( | ||
"density_matrix" if "noise_model" in self.options.backend_options else "automatic" | ||
) |
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.
Why is this line necessary? Shouldn't we just let AerSimulator set the method if it's not specified? It should default to automatic
, which should be smart enough to choose density_matrix
if noise_model
is specified.
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 removed this so now method=automatic
is set by default and #2117 is fixed
* fix init of EstimatorV2 and SamplerV2 to handle method * add release note * fix from_backend and example in README * remove setting density_matrix
Summary
Fixes #2117
Details and comments
This PR fixes init function of EstimatorV2 and SamplerV2 to store
method
option inself.options.backend_options
ifmethod
is not specified as input parameter