QNSPSA error using a dataset

Hey @Christophe_Pere!

I think you just need to update PennyLane to v0.36 :slight_smile:. v0.36 added Qiskit 1.0 device support. I can’t run a calculation on ibm_quebec (don’t have access to that), but this works for me:

import pennylane as qml
from pennylane import numpy as np

from qiskit_ibm_runtime import QiskitRuntimeService
provider = QiskitRuntimeService(channel='ibm_quantum', token='my_token')

dev = qml.device('qiskit.ibmq', wires=2, backend='ibmq_qasm_simulator', shots=10, provider=provider)

@qml.qnode(dev)
def cost(params):
    qml.RX(params[0], wires=0)
    qml.CRY(params[1], wires=[0, 1])
    return qml.expval(qml.Z(0) @ qml.Z(1))

params = np.random.rand(2)
opt = qml.QNSPSAOptimizer(stepsize=5e-2)

for _ in range(2):
    params, loss = opt.step_and_cost(cost, params)

Let me know if that helps!

1 Like