1
$\begingroup$

When I create a circuit using Qiskit and then transpile it using transpiled_circuit = transpile(circuit, ibm_backend, optimization_level=1) then I open my IBMQ account and go to circuit composer to draw the circuit and run it on the same backend, the transpiled circuit I got from the circuit composer is different from that from my qiskit code.

For example, I have the following circuit :

Quantum circuit

when I transpile it in my qiskit code transpiled_circuit = transpile(circuit, provider.get_backend('ibmq_athens'), optimization_level=1) I got the following circuit :

qiskit_transpiled_circuit Using the IBMQ experience circuit composer I got the following transpiled circuit when I run using ibmq_athens

transpile_circuit_qasm

I tried different optimization levels in qiskit and the transpiled circuit is also different.

My question is how I can get a transpiled circuit in qiskit to be the same as the one returned from IBMQ experience circuit composer.

$\endgroup$
0

4 Answers 4

1
$\begingroup$

I was able to obtain similar results to your IQX output using the routing_method='sabre' and layout_method='sabre' options.

$\endgroup$
1
$\begingroup$

Consider that the transpilation process is not deterministic and the output might vary in every run (seed_transpiler sets the PRNG seed).

from qiskit import *

circuit = QuantumCircuit(5, 5)
circuit.ccx(1,2,4)
circuit.ccx(2,3,4)
circuit.measure(4, 4)
circuit.draw('mpl')

enter image description here

transpile(circuit, provider.get_backend('ibmq_athens'), seed_transpiler=13).draw('mpl', fold=0)

enter image description here

$\endgroup$
0
$\begingroup$

The reason why your transpiled circuit you got from the circuit composer is different from that from your qiskit code is because the native gates on IBM's quantum hardware only consists of CNOT, and single qubit gates ($U_1, U_2, U_3$ ); and furthermore NOT all the qubits are connected to one another.

For Athen, you have:

enter image description here

And so when you execute your CCNOT gate, you must decompose it to the hardware native set of gates. This can be done as:

enter image description here

So here when you have a CNOT between two qubits that are not connected, you have to do some overhead swapping which resulted in a much longer circuit than what you orginally have.

This is why part of the Quantum Volume metric is also influenced by the qubits connectivity. Less connectivity implies you have to do more overhead gate execution resulting in longer circuit depth which in turns require longer qubit coherence...

$\endgroup$
9
  • $\begingroup$ I consider that the transpile function in qiskit do the required decompositions according to the backend I pass to it as an attribute and so I should get the same transpiled circuit I got from IBMQ @KAJ226 $\endgroup$ Dec 4, 2020 at 18:26
  • $\begingroup$ @MonicaMagdy The two bottom circuits are the same aren't they? $\endgroup$
    – KAJ226
    Dec 4, 2020 at 18:31
  • $\begingroup$ The 2 bottom circuits -> you mean the transpiled cirquit from qiskit and the transpiled circuit from IBM . $\endgroup$ Dec 4, 2020 at 18:37
  • $\begingroup$ @MonicaMagdy Yes. The two longer circuits. $\endgroup$
    – KAJ226
    Dec 4, 2020 at 18:38
  • $\begingroup$ To be honest, I haven't tried them. But they should give the same outputs $\endgroup$ Dec 4, 2020 at 18:39
0
$\begingroup$

transpiled_circuit = transpile(circuit, ibm_backend, seed_transpiler=13) gave me the circuit returned from IBMQ. Also I discovered that even on IBMQ, transpilation is random in most of the backends, in other words, when you run the same circuit many times on the same backend, you get different transpiled circuits.

$\endgroup$

Your Answer

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

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