Quantum Computing Asked by thespaceman on December 28, 2020
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?
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.
Correct answer by Matthew Treinish on December 28, 2020
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:
Answered by KAJ226 on December 28, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP