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

Sampler and Estimator with noise model doesn't work consistently for parametrized circuits #1798

Closed
HwajungKang opened this issue May 3, 2023 · 1 comment · Fixed by #1814
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@HwajungKang
Copy link

Informations

  • Qiskit Aer version: 0.12.0
  • Python version: 3.11
  • Operating system: osx

What is the current behavior?

Running parametrized circuits using Sampler or Estimator with noise model fails. Although it works when the noise model is built using certain fakebackends like FakeCambridge.

Steps to reproduce the problem

The following code works when backend2 is passed to the noise model but fails with backend1.
Same for Estimator as well.

from qiskit import *
from qiskit.circuit import ParameterVector
from qiskit.providers.fake_provider import FakeCambridge, FakeKolkata
from qiskit_aer.noise import NoiseModel
from qiskit_aer.primitives import Sampler

backend1, backend2 = FakeCambridge(), FakeKolkata()
noise = NoiseModel.from_backend(backend2)

run_opt = {'shots':10000}
backend_opt = {'noise_model':noise}

samp = Sampler(backend_options=backend_opt, run_options=run_opt)

ang = ParameterVector('x', 3)
qc = QuantumCircuit(1)
qc.u(*ang, [0])
qc.measure_all()

res = samp.run(qc, parameter_values=[1.3, 2.1, 0.7]).result()
print(res.quasi_dists)

What is the expected behavior?

It should work consistently regardless of what fakebackend is used for noise model.

Suggested solutions

@HwajungKang HwajungKang added the bug Something isn't working label May 3, 2023
@hhorii
Copy link
Collaborator

hhorii commented May 9, 2023

Thank you for your reporting. This is from the same reason of #1795.

Your parameterized circuit is transpiled with basis gates of noise. The transpiled circuit is as follows:

global phase: x[1]/2 + x[2]/2 - π/2
                 ┌──────────┐┌────┐┌──────────────┐┌────┐┌───────────────┐
        q_0 -> 0 ┤ Rz(x[2]) ├┤ √X ├┤ Rz(x[0] + π) ├┤ √X ├┤ Rz(x[1] + 3π) ├
                 └──────────┘└────┘└──────────────┘└────┘└───────────────┘

Its global phase includes parameter expressions, which are not correctly handled by the current implementation as reported #1795.

@hhorii hhorii added the duplicate This issue or pull request already exists label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants