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

Noisy simulations with EstimatorV2 behave as they are ideal for backend noise models #2312

Open
DilhanM opened this issue Feb 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@DilhanM
Copy link

DilhanM commented Feb 5, 2025

Informations

-Qiskit version: 1.3.2

  • Qiskit Aer version: 0.16.0
  • Python version: 3.11.5
  • Operating system: macOS 15.2

What is the current behavior?

Noisy and exact simulation results for EstimatorV2 primitives are identical when noise model is built from a backend.

Steps to reproduce the problem

This is the example from docs, with the noise model built from a backend.

from time import time

from qiskit import QuantumCircuit, generate_preset_pass_manager
from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_aer.primitives import EstimatorV2 as EstimatorAer

from qiskit.circuit.library import EfficientSU2
 
n_qubits = 8
circuit = EfficientSU2(n_qubits)

from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_aer import AerSimulator
from qiskit_aer.primitives import EstimatorV2 as Estimator
 
observable = SparsePauliOp("Z" * n_qubits)
params = [0.1] * circuit.num_parameters
 
exact_estimator = Estimator()
# The circuit needs to be transpiled to the AerSimulator target
pass_manager = generate_preset_pass_manager(3, AerSimulator())
isa_circuit = pass_manager.run(circuit)
pub = (isa_circuit, observable, params)
job = exact_estimator.run([pub])
result = job.result()
pub_result = result[0]
exact_value = float(pub_result.data.evs)

print("Exact value:", exact_value)

device = "ibm_brisbane"
service = QiskitRuntimeService(
    instance="YOUR INSTANCE"
)
backend = service.backend(device)
noise_model = NoiseModel.from_backend(backend)

#Works for custom noise models #
# from qiskit_aer.noise import depolarizing_error
# noise_model = NoiseModel()
# cx_depolarizing_prob = 0.02
# noise_model.add_all_qubit_quantum_error(
#     depolarizing_error(cx_depolarizing_prob, 2), ["cx"]
# )

noisy_estimator = Estimator(
    options=dict(backend_options=dict(noise_model=noise_model))
)
job = noisy_estimator.run([pub])
result = job.result()
pub_result = result[0]
noisy_value = float(pub_result.data.evs)

print("Noisy value:", noisy_value)

What is the expected behavior?

print("Noisy value:", noisy_value)` --> 0.7247404214143528

Other info

Issue is invariant to the backend used.

@DilhanM DilhanM added the bug Something isn't working label Feb 5, 2025
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

No branches or pull requests

1 participant