Skip to content
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

Merged
merged 9 commits into from
May 28, 2024

Conversation

doichanj
Copy link
Collaborator

@doichanj doichanj commented May 2, 2024

Summary

Fixes #2117

Details and comments

This PR fixes init function of EstimatorV2 and SamplerV2 to store method option in self.options.backend_options if method is not specified as input parameter

@doichanj doichanj added stable-backport-potential The issue or PR might be minimal and/or import enough to backport to stable Changelog: Bugfix Include in the Fixed section of the changelog labels May 2, 2024
@doichanj doichanj requested a review from hhorii May 2, 2024 06:19
@@ -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"
Copy link
Collaborator

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?

"density_matrix" if "noise_model" in self.options.backend_options else "automatic"
)
ops = dict(method=method)
self.options.backend_options.update(ops)
Copy link
Collaborator

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"
)

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.

Copy link
Collaborator Author

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

@doichanj doichanj mentioned this pull request May 23, 2024
@doichanj doichanj merged commit 7111188 into Qiskit:main May 28, 2024
38 checks passed
doichanj added a commit to doichanj/qiskit-aer that referenced this pull request May 28, 2024
* fix init of EstimatorV2 and SamplerV2 to handle method

* add release note

* fix from_backend and example in README

* remove setting density_matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the Fixed section of the changelog stable-backport-potential The issue or PR might be minimal and/or import enough to backport to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minor issue in EstimatorV2 __init__ - can't specify method in options
3 participants