I am attempting to intentionally add noise to my qiskit circuit by applying n-pairs of CNOT gates. The effect of this should be to yield the same result of my baseline (no pairs of CNOT gates applied) circuit with the addition of some noise. However, the result of my "noisy" circuit looks the same as my baseline even for large n. My best guess is that qiskit automatically removes unnecessary operations (like a pair of CNOTs) in an effort to reduce the number of gates. If this is true, then how can I add a series of gates which will keep the baseline circuit the same but will add gate noise?


2 Answers 2


Yes, Qiskit's transpiler will optimize the circuit and remove redundant gates automatically. For normal operation this is desired behavior. However for cases like this where you don't want to transpiler to optimize the circuit for you and you want to send the circuit to the backend in a raw form (it will still fit it to the backend based on its constraints) you can use optimization_level=0 kwarg for transpile() and execute(). This disables all the optimization passes and will just run the transforms necessary to run on the device (basis gate transformation, layout, routing) For example, when using execute() it would be: qiskit.execute(circuit, backend, optimization_level=0)

If you want to experiment with the transpiler you can just call qiskit.transpile(circuit, backend) which will return a circuit that has been transformed so it is optimized and will be able to run on the backend. This gets internally called by execute() prior to sending a job to the backend so you can see what transforms are happening and tune things for your use case.

The documentation on transpiler covers how the transpiler works pretty well: https://qiskit.org/documentation/apidoc/transpiler.html and the tutorial https://qiskit.org/documentation/tutorials/circuits_advanced/4_transpiler_passes_and_passmanager.html has examples on how you can work with it.


I am assuming you are probably trying to do error mitigation using extrapolation technique giving in this paper: https://arxiv.org/abs/1801.03897

The other answer is great and perfectly fine.

I just want to add that, you could also use circuit barrier as a way to tell Qiskit not to optimize the consecutive CNOT gates.

For example:

enter image description here

  • $\begingroup$ You are correct! This is very helpful as well, thank you. $\endgroup$ Oct 28, 2020 at 22:37
  • $\begingroup$ Follow up question, in the Dumitrescu et al. (2018) paper that you cited do you understand what is meant on page 4 when they say "...using ten iterations of 8,192 measurements..." What are the iterations that they refer to? $\endgroup$ Oct 29, 2020 at 0:17
  • 1
    $\begingroup$ The "ten iterations" prefers to the number of time it passes through the classical optimizer. The 8,192 prefers to the number of shots they used on each circuit. 8,192 is the maximum number of shots you are allowed to use on IBM's machine. $\endgroup$
    – KAJ226
    Oct 29, 2020 at 0:42

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.