Qiskit / qiskit-aer

Aer is a high performance simulator for quantum circuits that includes noise models
https://qiskit.github.io/qiskit-aer/
Apache License 2.0
464 stars 354 forks source link

Fix from backend of V2 primitives to use existing AerSimulator #2173

Open doichanj opened 2 weeks ago

doichanj commented 2 weeks ago

Summary

This PR fixes EstimatorV2.from_backend and SamplerV2.from_backend to use pre-defined AerSimulator for simulation

Details and comments

With this fix, user can define specific simulator object with backend options instead of passing options for V2 primitives.

for example, following script can use AerSimulator with statevector simulation and with noise model

sim = AerSimulator(method="statevector", noise_model=noise_model)
estimator = EstimatorV2.from_backend(sim)

This PR fixes from_backend that initialized backend object by calling AerSimulator.from_backend but when input backend is AerSimulator just copy it.