Error returning expval with qiskit device

I’m trying to use qiskit’s Aer simulator in my Pennyalne program but I get an error when te circuit tries to return an expected value:

‘RY’ object has no attribute ‘return_type’

Here is a simple example:

def circuit1():
    qml.RY(np.pi/4, wires=0)
    return qml.expval(qml.PauliZ(wires=0))

dev1 = qml.device("qiskit.aer", wires=1)
node = qml.QNode(circuit1, dev1)

fig,ax=qml.draw_mpl(node,expansion_strategy="device", decimals=1)()



Thank you in advance!

Hi @psansebastian, welcome to the Forum!

I’m running your circuit on a notebook Xanadu Cloud and I get no errors. Could you please post the output of qml.about()? I’m guessing that you might be using an old version of PennyLane. You can use python -m pip install pennylane --upgrade to make sure you’re using the latest version.

Please let me know if this solves your issue!

Thank you for replying! Seems that updating Pennylane fixed it!

I’m glad this solved your issue @psansebastian!

Enjoy using PennyLane :grinning: