Quantum Computing Asked on May 10, 2021
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 :
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 :
Using the IBMQ experience circuit composer I got the following transpiled circuit when I run using ibmq_athens
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.
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.
Correct answer by Monica Magdy on May 10, 2021
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:
And so when you execute your CCNOT gate, you must decompose it to the hardware native set of gates. This can be done as:
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...
Answered by KAJ226 on May 10, 2021
I was able to obtain similar results to your IQX output using the routing_method='sabre'
and layout_method='sabre
' options.
Answered by user14041 on May 10, 2021
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')
transpile(circuit, provider.get_backend('ibmq_athens'), seed_transpiler=13).draw('mpl', fold=0)
Answered by luciano on May 10, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP