I am trying to obtain the correct circuit transpiled for the ibmq_london device, as I want to know what the real gates applied in the quantum computer are. I am implementing the QFT circuit for 5 qubits. My code is the following one (DAQC and qnoise are modules that I have created but they do not affect the transpilation, they are used to show the pictures or to create initial states):

    import numpy as np
    from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister, IBMQ, execute
    from qiskit.providers.aer import QasmSimulator
    from qiskit.visualization import plot_histogram
    from qiskit.compiler import transpile
    import DAQC

    provider = IBMQ.load_account() 
    # Get properties and coupling map of the desired device
    device = provider.get_backend('ibmq_london')
    properties = device.properties()
    coupling_map = device.configuration().coupling_map
    # Circuit
    backend = QasmSimulator()
    job = execute(qc, backend=backend,shots=100000)
    result_ideal = job.result()
    qnoise.show_figure(plot_histogram(qiskit_counts, title='Results for qiskit ideal simulator'))
    # Transpiled circuit
    job = execute(qc2, backend=backend,shots=100000)
    result_ideal = job.result()
    qnoise.show_figure(plot_histogram(qiskit_counts, title='Results for qiskit ideal simulator (transpiled)'))

The problem is that when I obtain the results, although they should be the same because the circuit is just transpiled, I obtain completely different outcomes:

enter image description here

enter image description here

I think that the problem is with the initialize command, as when I remove it I obtain the same result for both cases. Is it possible to use the initialize command with the transpile one? Is there any other option to obtain the transpiled circuit when it is initialized in a concrete state?

Thank you

  • 2
    $\begingroup$ It looks like you're transpiling with the coupling_map and basis gates, but when you run the circuit without transpiling, you are not using these. This will most likely cause a large difference between your 2 circuits which might also be contributing to the difference in results $\endgroup$ Jul 9, 2020 at 15:10
  • $\begingroup$ But the results must be the same if we transpile the circuit than the ones before doing that, as both circuits must be equivalent, otherwise transpiling the circuit makes no sense. The gates applied after the transpilation must lead to the same result, they are just a decompostion of the other gates so the effect is the same and hence, the ideal result. $\endgroup$
    – Paula G
    Jul 9, 2020 at 17:36
  • 1
    $\begingroup$ Hi! What version of qiskit you are currently running your code with? I have heard several times that previous versions may create bugs like the one you have. If you don't have the latest version I suggest you to install it and re-run your code. Hope this works! Also could you look at the two circuits and tell me what are the biggest differences between the two? Adding the basis_gates and coupling_map should add some changes but not that much to have the result you have. $\endgroup$
    – Lena
    Jul 10, 2020 at 9:21
  • $\begingroup$ I do not know how to check my qiskit version but it is from 2019. I cannot update it because I have written a code based on that version and the possible changes in the new version could break my code. The circuits are completely different. Moreover, when I compare the ibmq_london results with the ideal for this algorithm (about 40-50 gates) I obtain a very low fidelity, about 0.3 or so. $\endgroup$
    – Paula G
    Jul 10, 2020 at 13:18
  • $\begingroup$ I have tried a new qiskit version and I still have the same result :( $\endgroup$
    – Paula G
    Jul 10, 2020 at 14:41

1 Answer 1


I have found the solution! The problem is that each time you use the transpile function, it generates a different transpiled circuit and the order of the outcome is not necessary the same as the order of the input, so you have to use swap gates to obtain the correct one. In order to always obtain the same circuit you have to fit the seed_transpiler (as with any random seed).


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.