I am trying to understand how to use the noise model of real hardware. Below is the part of the code I have written with the help of sample codes from these links:




I have a lot of questions which I still not able to understand. What is depolarizing_error ? Are we adding somekind of error to the existing errors of ibm_cairo ? I have added some gates to the API add_all_qubit_quantum_error?How can I know what all gates I have in my quantum circuit? Can I use qasm_simulator instead of AerSimulator. If possible then how?

    prob_1 = 0.001  # 1-qubit gate
    prob_2 = 0.01   # 2-qubit gate
    # Depolarizing quantum errors
    error_1 = noise.depolarizing_error(prob_1, 1) # I think, one means here 1 qubit
    error_2 = noise.depolarizing_error(prob_2, 2) # I think, two means here 2 qubit
    # Add errors to noise model
    noise_model = noise.NoiseModel()
    noise_model.add_all_qubit_quantum_error(error_1, ['u1', 'u2', 'u3','x','y','z','h','s','t'])  
    noise_model.add_all_qubit_quantum_error(error_2, ['cx','cy','cz', 'swap'])
    # Get basis gates from noise model
    basis_gates = noise_model.basis_gates
    # provider = IBMQ.load_account()
    provider = IBMQ.get_provider(hub=' ', group=' ', project=' ')
    backend_cairo = provider.get_backend('ibm_cairo')
    noise_model = NoiseModel.from_backend(backend_cairo)
    # Get coupling map from backend
    coupling_map = backend_cairo.configuration().coupling_map
    # Perform a noise simulation
    backend = AerSimulator(noise_model=noise_model,
    transpiled_circuit = transpile(qc_combine, backend)
    result = backend.run(transpiled_circuit, shots= self.shots_done).result()

Edit If the modify the code as below, then how backend getting the NoiseModel. Please review.

provider = IBMQ.get_provider(hub=' ', group=' ', project=' ')
backend_cairo = provider.get_backend('ibm_cairo')
noise_model = NoiseModel.from_backend(backend_cairo)
backend = AerSimulator.from_backend(backend_cairo)
  • $\begingroup$ (1) You need to load the account before getting the provider if IBMQ.active_account() is None: IBMQ.load_account() (2) You need to pass valid values for hub, group, and project (e.g., IBMQ.get_provider(hub='ibm-q', group='open', project='main')) (3) Make sure you have access to the backend ibm_cairo (here is the list of available backends) $\endgroup$ Commented Mar 19 at 7:38
  • $\begingroup$ After putting details of hub, group and project, the above code works well @Egretta.Thula. My question is that do I have to put the noise_model some how as a argument in backend = AerSimulator.from_backend(backend_cairo) like backend = AerSimulator.from_backend(backend_cairo, noise_model= noise_model)? $\endgroup$
    – Manu
    Commented Mar 19 at 15:35
  • $\begingroup$ You don't need to pass noise_model. $\endgroup$ Commented Mar 19 at 16:56
  • $\begingroup$ Thank you @Egretta.Thula for great help. $\endgroup$
    – Manu
    Commented Mar 19 at 16:59

1 Answer 1


If all what you want is to derive a noise model from the properties of a real quantum device, then you just need to use NoiseModel.from_backend() method:

noise_model = NoiseModel.from_backend(backend_cairo)

Methods like add_all_qubit_quantum_error() are needed if you want to build your own custom noise model.

If, however, you want your simulator to mimic the other real device properties like coupling map and basis gateset in addition to the noise model, then you can call AerSimulator.from_backend()

simulator = AerSimulator.from_backend(backend)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.