Skip to content

Using ZNE with Aer primitives #49

Description

@NicoRenaud

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew non-feature request (e.g. performance)triagePending assessment

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions