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

Using ZNE with Aer primitives #49

Open
1 task done
NicoRenaud opened this issue Jul 5, 2023 · 0 comments
Open
1 task done

Using ZNE with Aer primitives #49

NicoRenaud opened this issue Jul 5, 2023 · 0 comments
Labels
enhancement New non-feature request (e.g. performance) triage Pending assessment

Comments

@NicoRenaud
Copy link

What is the current behavior?

Thanks a lot for all your work on this prototype ! I waned to use it with the Aer Estimator primitive. However since qiskit.primitives.Estimator and qiskit_aer.primitives.Estimator have different call signature I don't think that works at the moment.

The issue is that the zne init function passes the options kwarg explicitly. That matches the call of qiskit.primitives.Estimator and qiskit.primitves.BackendEstimator but not the call of the qiskit_aer.primitives.Estimator

As a result, the following code:

from qiskit.providers.fake_provider import FakeNairobi, FakeGuadalupeV2, FakeGuadalupe
from zne import zne, ZNEStrategy
from zne.noise_amplification import LocalFoldingAmplifier
from zne.extrapolation import PolynomialExtrapolator
from qiskit.circuit.random import random_circuit
from qiskit.quantum_info import SparsePauliOp
from qiskit_aer.primitives import Estimator as AerEstimator
from qiskit_aer.noise import NoiseModel

## Build our input circuit and observable
circuit = random_circuit(2, 4, seed=1).decompose(reps=1)
observable = SparsePauliOp("ZZ")

# create noise model
seed = 170
device = FakeGuadalupe()
coupling_map = device.configuration().coupling_map
noise_model = NoiseModel.from_backend(device)

# Build ZNEEstimator
ZNEEstimator = zne(AerEstimator)
estimator = ZNEEstimator(backend_options={
        "method": "density_matrix",
        "coupling_map": coupling_map,
        "noise_model": noise_model,
    },
    run_options={"seed": seed, "shots": 10000},
    transpile_options={"seed_transpiler": seed},)

returns the following error:

TypeError: __init__() got an unexpected keyword argument 'options'

What is the expected enhancement?

It would be great to be able to use the prototype with the AER estimators !

Context

No response

Suggestions

I think the only change needed is to not pass the options keyword argument as part of the zne init function.
I've forked the repo and made that simple change here

With that change, the prototype works well with the Aer estimator, but I'm not 100% sure if it's breaking something else.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@NicoRenaud NicoRenaud added enhancement New non-feature request (e.g. performance) triage Pending assessment labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New non-feature request (e.g. performance) triage Pending assessment
Projects
None yet
Development

No branches or pull requests

1 participant