I'm trying to do error mitigation in IBM-Q quantum computers with qiskit. I followed the tutorial here. My thought was that in order to make sure that I'm correcting the qubits that I'm actually using in my circuits, I should specify the backend and qubits to make sure that the qubits used in my actual circuit and obtaining the correcting matrix are the same. I asked this question and followed along, but I have encountered some problems. Here is the part that is causing problem:

    qreg = qk.QuantumRegister(7)
    layout = {qreg[0]: 12, 
              qreg[1]: 11,
              qreg[2]: 13, 
              qreg[3]: 17, 
              qreg[4]: 14, 
              qreg[5]: 12, 
              qreg[6]: 6}

    ########## error mitigation ##########

    meas_calibs, state_labels = complete_meas_cal(
            qubit_list=[0, 1, 2], qr=qreg, circlabel='mcal') 

    # This line below is causing error if I add "initial_layout" in both qk.compiler.transpile and qk.execute
    qk.compiler.transpile(meas_calibs, backend=_backend, initial_layout=layout)

I receive the error

qiskit.dagcircuit.exceptions.DAGCircuitError: 'not a DAG' 

whenever I specify the layout. I googled about this error but found nothing. So my question is, what does this error mean? What have I done wrong and how can I fix it?

Thank you in advance.


You have assigned 2 virtual qubits to the same physical qubit, both qreg[0] and qreg[5] are assigned to physical qubit 12. If you change one of these to be a different physical qubit, it should work.

  • $\begingroup$ Ah, thank you. Sorry for making such a stupid mistake :( $\endgroup$ – Frank Wang May 19 '20 at 12:43
  • $\begingroup$ No worries at all, we all do it :) $\endgroup$ – met927 May 19 '20 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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