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

Minor issue in EstimatorV2 __init__ - can't specify method in options #2117

Closed
zlatko-minev opened this issue May 1, 2024 · 0 comments · Fixed by #2120
Closed

Minor issue in EstimatorV2 __init__ - can't specify method in options #2117

zlatko-minev opened this issue May 1, 2024 · 0 comments · Fixed by #2120
Labels
bug Something isn't working

Comments

@zlatko-minev
Copy link

zlatko-minev commented May 1, 2024

Informations

  • Qiskit Aer version: 0.14.1
  • Python version: 3.11
  • Operating system: mac

What is the current behavior?

Minor issue in EstimatorV2 init - can't specify method in options,

from qiskit_aer.primitives import EstimatorV2

options = {
    "backend_options": {
        "method" : "matrix_product_state"
    }
}
estimator = EstimatorV2(options=options)

Fails with

--->  self._backend = AerSimulator(method=method, **self.options.backend_options)

TypeError: qiskit_aer.backends.aer_simulator.AerSimulator() got multiple values for keyword argument 'method'

Steps to reproduce the problem

See code above

What is the expected behavior?

Should be able to specify the method at the options level

Suggested solutions

Combine the dicts like this

    def __init__(
        self,
        *,
        options: dict | None = None,
    ):
        """
        Args:
            options: The options to control the default precision (``default_precision``),
                the backend options (``backend_options``), and
                the runtime options (``run_options``).
        """
        self._options = Options(**options) if options else Options()
        method = "density_matrix" if "noise_model" in self.options.backend_options else "automatic"
        ops = dict(method=method) 
        ops.update(self.options.backend_options)
        self._backend = AerSimulator(**ops)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant