How can I specify the qubits on quantum computers that I want to use?

Suppose I have the following 2-qubit quantum circuit:

qrz = QuantumRegister(2,'q')
crz = ClassicalRegister(3,'c')
qc = QuantumCircuit(qrz,crz)
qc.rx(np.pi/3,0)
qc.cry(np.pi/2,0,1)


I want to run this circuit on a real quantum computer, depending on the real-time error rate, I might want to use different qubits on the hardware. For example, suppose here's the calibration data of my backend:

Is there a way I can specify that I want to use qubit 4 and 5 on this quantum computer? I tried to generate a quantum circuit with 6 qubits and append my quantum circuit to qubit 4 and 5, then run the entire circuit on that quantum computer. Is there a simpler way I can do that without generating another large circuit? Thanks!

• Same questions here, every time using ibmq I have to create a circuit with number of qubits equal number of qubits in the ibmq machine. May 31 at 2:00

Why not just use initial_layout method?

For instance,

from qiskit import IBMQ, QuantumCircuit
from qiskit.aqua import QuantumInstance
circuit = QuantumCircuit(2,2)
circuit.h(0)
circuit.x(1)
quantum_instance = QuantumInstance(backend= provider.get_backend('ibmq_santiago'),
shots = 8192,
initial_layout = [3,4],
optimization_level = 3)
results = quantum_instance.execute(circuit)


If you go and look at the circuit that being executed, you will see that it uses qubit 3 and 4 of the device:

If you don't to use quantum_instance but instead you want to use execute class directly, then you can just specify the initial_layout method in execute. For example:

result = execute(circuit, backend=provider.get_backend('ibmq_santiago'),
initial_layout = [3,4], shots= 1000)


This will also make sure qubit 3 and 4 of the hardware are use when you execute your circuit.

... depending on the real-time error rate, I might want to use different qubits on the hardware.

Qiskit provides a transpiler pass that chooses a noise-adaptive layout based on current calibration data for the backend; NoiseAdaptiveLayout.

To use it, first transpile your circuit with the parameter layout_method equals "noise_adaptive"

transpiled_circuit = transpile(qc, backend = chosen_backend, layout_method = "noise_adaptive")


Then execute the transpiled circuit:

qobj = assemble(transpiled_circuit)
chosen_backend.run(qobj)

• Thanks for the answer! That's really helpful. I just tried that method on ibmq_casablanca. However, the calibration data shows that qubit 4 and 5 as well as their connection has the lowest error rate, but the system picked qubit 5 and 6 for me. Is that more noise adaptive?
– ZR-
May 31 at 14:50
• I'm just providing a general answer to the question I quoted at the beginning. For simple circuits, like the one in your question, may be the best option you have is to follow @KAJ226 suggestion. May 31 at 18:15
• Got it. Thanks!
– ZR-
May 31 at 19:25