Hi, I have a hybrid quantum-classical machine learning program which I am running on IBMQ backends using the qiskit-pennylane plugin. For each classical data-point, I need to run the quantum circuit with classical post processing of the expectation values. When running on IBMQ backends, the execution of each circuit corresponding to each data-point is submitted as a separate job. I was wondering if it is possible to use Qiskit Runtime Session with Pennylane circuit so that the whole program is submitted to IBMQ backend as a single job, and I do not have to wait in queue.
I am initializing “dev” in the following way-
dev = qml.device("qiskit.ibmq.circuit_runner", wires=n_qubits, backend="ibmq_quito", ibmqx_token=token)
Before running the loop on data points, I add-
with Session(service = service, backend = "ibmq_quito"):
but this does not work as the jobs are still being submitted as separate jobs. Is there a way to submit it as a single job?
Great question. This sounds a little strange to me… I’m going to confirm a couple things with some of our development team and I will get back to you as soon as I can
Hi @isaacdevlugt this function does not seem to be useful. I have only one circuit which needs to run once for each data point. For example, a variational quantum circuit is trained for a model, and now I predict each data-point from the test set. I want that for the whole test dataset, the IBMQ device will be reserved for me (which you can achieve using Qiskit Runtime session), and I do not have to wait in queue for every data point.
I cannot use Qiskit runtime service because my network is a mixture of classical and quantum layers, where the quantum layer is defined as a pytorch nn.Module.
@isaacdevlugt unfortunately the link does not work.
I currently have the same issue: Starting an IBMQ session in Pennylane to train a hybrid quantum machine learning model. Do you already have a solution?
Dear @ CatalinaAlbornoz, thany you very much for your answer.
Scince I am using Qiskit 1.0 your code works and I can start a session on the IBM Quantum Platform.
Unfortunately, I have now a new issue: I am training a hybrid Quantum Machine Learning Model and every data point of a batch becomes an own job.
Previously I used qiskit 0.9 and it was possible to run a whole batch in one job. With Qiskit 0.9 I used the plugin “qiskit.ibmq” instead of “qiskit.remote”, which is obviously not avaible with Qiskit 1.0.
So my question would be if you know how I can run a whole batch with multiple data points in one job.
Thank you very much in advance and best regards
Stefan
Unfortunately Qiskit is no longer allowing you to run jobs together in a session as seen here in the Qiskit docs:
Session execution mode is not supported in the Open Plan. Jobs will run in job mode instead.
This means that there’s not really anything we can do on the PennyLane side.
If you have a Premium IBM plan you can probably open a context manager with a session (I can show you a code example if needed) but it’s not guaranteed to work since we cannot test it.
Within a session every data point becomes an own job. This is fine for me.
I now have the following problem: After the first Epoch, which was evaluated on an ibm quantum computer (ibmq), I receive the following error massage and the code aborts:
qiskit_ibm_runtime.exceptions.IBMRuntimeError: ‘Exception encountered when calling layer “QVC_PS” (type KerasLayer).\n\nThe session is closed.\n\nCall arguments received:\n • inputs=tf.Tensor(shape=(32, 6), dtype=float64)’
When I run the exact same code with the “default.qubit” backend everything works fine. I checked that the output of the QVC has the same dimension regardless of the backend.