VQE Runtime not working on real quantum computers

Hi!

I am experiencing problems running VQE programs from PennyLane on actual quantum computers.

I am using the code from PennyLane’s tutorial:

from pennylane_qiskit import upload_vqe_runner, vqe_runner

IBMQ.enable_account(token)

program_id = upload_vqe_runner(hub="ibm-q", group="open", project="main")

def vqe_circuit(params):
    qml.RX(params[0], wires=0)
    qml.RY(params[1], wires=0)

coeffs = [1, 1]
obs = [qml.PauliX(0), qml.PauliZ(0)]
hamiltonian = qml.Hamiltonian(coeffs, obs)

job = vqe_runner(
    program_id=program_id,
    backend="ibmq_qasm_simulator",
    hamiltonian=hamiltonian,
    ansatz=vqe_circuit,
    x0=[3.97507603, 3.00854038],
    shots=shots,
    optimizer="SPSA",
    optimizer_config={"maxiter": 40},
    kwargs={"hub": "ibm-q", "group": "open", "project": "main"},
)

This works perfectly. However, when I substitute “ibmq_qasm_simulator” with, for instance, “ibm_oslo”, I obtain the following error:

HTTPError: 403 Client Error: Forbidden for url: https://runtime-us-east.quantum-computing.ibm.com/jobs

The above exception was the direct cause of the following exception:

RequestsApiError                          Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/qiskit/providers/ibmq/api/session.py in request(self, method, url, bare, **kwargs)
    298                 self._modify_chained_exception_messages(ex)
    299 
--> 300             raise RequestsApiError(message, status_code) from ex
    301 
    302         return response

RequestsApiError: '403 Client Error: Forbidden for url: https://runtime-us-east.quantum-computing.ibm.com/jobs. {"errors":[{"code":"forbidden","message":"user not authorized to run program vqe-runtime-M6ZRlLEo86","more_info":"https://cloud.ibm.com/apidocs/quantum-computing#error-handling"}],"trace":"cfa0d7qb2ktmne14rdq0"}'

Any help with this would be greatly appreciated!

Thanks!

Hi @combarro,

Thank you for reporting this. I’m being able to reproduce your problem. We will look into the cause of the problem.

@Romain_Moyard, do you have any ideas on what could be the issue?

Hi @combarro ,

Not all hardware are available for runtime and not all users can run runtime programs on some hardware. Could you check what is the output of that:

from qiskit_ibm_runtime import QiskitRuntimeService

# Initialize the account first.
service = QiskitRuntimeService()
services = service.backends()
print(services)

Hi @Romain_Moyard,

Thanks for taking a look at this. I have run the code you suggested and my output is the following:

[<IBMBackend('ibmq_qasm_simulator')>, <IBMBackend('ibmq_armonk')>, <IBMBackend('ibmq_santiago')>, <IBMBackend('ibmq_casablanca')>, <IBMBackend('ibmq_lima')>, <IBMBackend('ibmq_belem')>, <IBMBackend('ibmq_quito')>, <IBMBackend('simulator_statevector')>, <IBMBackend('simulator_mps')>, <IBMBackend('simulator_extended_stabilizer')>, <IBMBackend('simulator_stabilizer')>, <IBMBackend('ibmq_jakarta')>, <IBMBackend('ibmq_manila')>, <IBMBackend('ibm_lagos')>, <IBMBackend('ibm_nairobi')>, <IBMBackend('ibm_perth')>, <IBMBackend('ibm_oslo')>]

I should also mention that the code that is now giving me trouble used to run with no problem a few weeks ago. I did not change anything, not even the name of the backend, but now it raises the error you can see on the OP.

Thanks once again!

Thanks for the details! Unfortunately I think the new Qiskit release introduced some breaking changes for custom runtime program. We will keep you updated.

Thanks!

What seems strange to me is that this code still works when the backend is ibmq_qasm_simulator, but not with ibm_oslo or ibmq_manila.

Hi @combarro, it’s possible that the hardware backends connect differently through runtime now so this is probably what’s causing problems. We will look further into this to see how it can be fixed. However it may take a several weeks (or may even be unfeasible) since the changes look very significant. Is there an urgency in your need to use the hardware through runtime?

Hi! Thanks for looking into this. The thing is that we are writing a book on quantum machine learning using Qiskit and PennyLane. It is almost done and will enter production in the next few weeks. We included a section on how to run VQE with PennyLane using Runtime. Everything worked perfectly, but when we checked all the code once again, we found this error.

That book sounds great @combarro !
It would be great if you could share a link to the book (or where to get it) when you have it ready :grinning:

Yes, everything worked perfectly before but Qiskit made significant changes recently so we’re having to change how we interface with them.

@Romain_Moyard or I will give you an update when we have more information about what can be fixed and when.

Thank you!

The book will be published by Packt later this year and it is already listed on Amazon: https://www.amazon.com/-/es/Elías-Fernández-Combarro-Álvarez/dp/1804613835/

The cover and some of the details are not final yet, though.

Thanks for your help. Looking forward to news from @Romain_Moyard

1 Like

Thank you for sharing the link to your book @combarro!