Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.86k stars 2.29k forks source link

Runtime estimator error: 'Unable to retrieve job result.' #9599

Closed TheVanisher2000 closed 1 year ago

TheVanisher2000 commented 1 year ago

Environment

What is happening?

I started to experiment the first time with qiskit runtime instead of the aer_simulator on which my code is running perfectly fine. The error I got is the following: 'Unable to retrieve job result. (...) WARNING Backend (qasm_simulator) does not support dynamical decoupling. (...)'

How can we reproduce the issue?

To reproduce just run the code: (Some imports migth be not needed)

!pip install pylatexenc !pip install qiskit !pip install qiskit-ibm-runtime

from qiskit import transpile from qiskit import execute import qiskit.quantum_info as qi from qiskit.extensions import UGate from qiskit.quantum_info import SparsePauliOp from qiskit_ibm_runtime import QiskitRuntimeService, Session, Estimator, Options

import numpy as np from numpy import array from numpy import dot from numpy import zeros from numpy import ones import random

#######################################

Control Parameters

####################################### shots = 1 e = 0.2 NCircuits = 1 Nqbits = 12 timeL = 80 service = QiskitRuntimeService(channel="ibm_quantum") Z = SparsePauliOp("ZZZZZZZZZZZZ")

Creating the input for the task

u_l1 = ones(50) u_l2 = np.random.uniform(0,1,30) u_l = np.concatenate((u_l1,u_l2),axis=0)

Repeating the whole circuit Nm times

for Nm in range(NCircuits):

ProbE = np.random.rand(timeL)
ProbU = np.random.rand(timeL)

for l in range(u_l.size):

    qcfinal = QuantumCircuit(Nqbits)

    #Appending l subcircuits
    for j in range(l+1):

        #Initialize control qbits for every subcircuit new
        if ProbU[j] <= u_l[j]:
            init = [1,0]
        else:
            init = [0,1]
        if ProbE[j] <= e:
            init2 = [0,1]
        else:
            init2 = [1,0]
        qcfinal.initialize(init,5)
        qcfinal.initialize(init2,11)

        #Resetting the exchange Qbits after every subcircuit to 
        #0 that a reset can occur with probability e
        qcfinal.initialize([1,0],6)
        qcfinal.initialize([1,0],7)
        qcfinal.initialize([1,0],8)
        qcfinal.initialize([1,0],9)
        qcfinal.initialize([1,0],10)

        #Apply U1
        qcfinal.cu(4.26, -1.14, -0.198,0,5,0)
        qcfinal.cu(-1.84, 3.54, -2.07,0,5,1)
        qcfinal.cu(5.34, 0.186, 2.96,0,5, 2)
        qcfinal.cu(-3.31, 4.03, -3.7,0,5, 3)
        qcfinal.cu(3.69, -3.84, 3.92,0,5, 4)
        qcfinal.barrier()

        #Apply U0
        qcfinal.cx(0,1)
        qcfinal.cx(1,2)
        qcfinal.cx(1,3)
        qcfinal.cx(3,4)
        qcfinal.barrier()

        #Apply U0dc
        qcfinal.ccx(5,3,4)
        qcfinal.ccx(5,1,3)
        qcfinal.ccx(5,1,2)
        qcfinal.ccx(5,0,1)
        qcfinal.barrier()

        #Apply Swap
        qcfinal.cswap(11,0,6)
        qcfinal.cswap(11,1,7)
        qcfinal.cswap(11,2,8)
        qcfinal.cswap(11,3,9)
        qcfinal.cswap(11,4,10)
        qcfinal.barrier()

    #Run experiment and get counts of total state for every time step l
    with Session(service=service, backend="ibmq_qasm_simulator") as session:
        estimator = Estimator(session=session)
        # calculate [ qcfinal|Z|qcfinal ]
        qcfinal_Z = estimator.run(circuits=qcfinal, observables=[Z])
        qcfinal_Z.result()
        session.close()

What should happen?

If I run the same code with the aer simulator, the code is just working fine. (Code above is simplified and the aer_simulator code looks actually a little bit different.)

Any suggestions?

No response

jacobwatkins1 commented 1 year ago

Could you comment on how you resolved this issue? I have ran into the exact same problem on my mac.

TheVanisher2000 commented 1 year ago

How I solved the problem is probably not useful for you. I modified my quantum circuit in many steps. The above code is representing 3 operators that can be performed on a certain amound of qubits. What I wanted to implement was a circuit which applies one out of three gates per time step with a certin probability. In my final result I only have the above gates U0 and U1 and not their controlled version and instead of the qc.initialize() command I added another command to reset the qubits to their intitial state (so qc.initialize() - command was deletetd from the code). Maybe this helps you, but to be honest I still don't know what exactly the dynamical decoupling means.