I'm learning how to do error mitigation on Qiskit as my experiment result differs from the simulated result. I read the tutorial here, but I have some questions about it. If I have understood it correctly, we take each basis states and measure them, to find the mitigation matrix, then execute my experiment, obtain the result, then recover the correct result using the mitigation matrix. That means I have to execute two experiment. However, how do I ensure that the qubits that I use to find the mitigation matrix is the same as the qubits that I do my actual experiment?

For example, let's say I want to execute an experiment with 3 qubits. I first run a code like the one in the tutorial. The compiler (or whatever compiles my code into instructions) uses qubit A, B and C. Then, when I execute my actual experiment, the compiler may use qubit D, E and F. As the qubits are different, then I think the mitigation will not be valid? Am I correct? if so, then how do we solve this? Obviously we have to use the same backend but I think that is achievable, but I found no way to specify which qubits to use.

Thank you in advance!


1 Answer 1


You can achieve this by providing a seed to the transpiler which guarantees that the layout will be the same every time you run it. This can be done as follows

job = execute(my_circuit, seed_transpiler=123)

Alternatively, if you would like to specify the layout yourself, you can do this by providing an initial_layout to the transpiler, and then setting the optimization_level=0. There are many potential formats for the initial layout, but the easiest to understand is a dictionary of the qubits in your circuit, to the physical qubits you would like them to take, for example {qr[0] : 3, qr[1]: 2}.

Overall, your code could then look something like this

my_layout = {qr[0] : 3, qr[1]: 2}
job = execute(my_circuit, initial_layout=my_layout, optimization_level=0)

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.