I'm currently attempting to simulate depolarizing errors using Qiskit, but I'm encountering an issue where it appears that no errors are being introduced into my simulation. After running the simulation, the output seems to indicate a perfect execution ({'00': 1024}), which suggests that the depolarizing errors are not being applied as expected. Below is the code snippet I've used for this simulation:

from qiskit import QuantumCircuit, Aer, execute
from qiskit.providers.aer.noise import NoiseModel, depolarizing_error

# Create a 2-qubit quantum circuit
qc = QuantumCircuit(2, 2)
qc.measure([0, 1], [0, 1])

# Define the depolarizing error
depolarizing_prob = 0.1  # Example probability
dep_error = depolarizing_error(depolarizing_prob, 1)  # Single-qubit error
dep_error_2q = depolarizing_error(depolarizing_prob, 2)  # Two-qubit error

# Add noise to an all-to-all quantum circuit
noise_model = NoiseModel()
noise_model.add_all_qubit_quantum_error(dep_error, ['i', 'id', 'u1', 'u2', 'u3'])  # Apply to single-qubit gates
noise_model.add_all_qubit_quantum_error(dep_error_2q, ['cx'])  # Apply to 2-qubit gates

# Simulate the circuit with noise
simulator = Aer.get_backend('qasm_simulator')
job = execute(qc, simulator, noise_model=noise_model, shots=1024)
result = job.result()
counts = result.get_counts(qc)

I'm puzzled as to why the errors do not seem to be affecting the simulation outcome. Could anyone provide insights into what might be going wrong or suggest any modifications to ensure that the depolarizing errors are correctly simulated?

Thank you in advance for your help!

  • 1
    $\begingroup$ Did you configure the default optimization level in settings.conf file? $\endgroup$ Mar 27 at 23:21
  • $\begingroup$ Thank you, I was able to resolve the issue with your help. $\endgroup$ Mar 27 at 23:37


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.