Hi, I’ve been working on QML for a research project and patched some code using TensorFlow and PennyLane. While the simulation works well, I wanted to ask how the job submission works. Using Qiskit, I can submit a collection of non-executed circuits via IBMQJobManager, so when I get the result, it’s the output of the entire batch. But when I use TensorFlow-Keras Model’s fit function, I can see that only one circuit is submitted. Is there a way to tell PennyLane to submit the entire batch?
Hi @jackaraz! What version of PennyLane are you using? The latest versions (v0.20) of both PennyLane and the PennyLane-Qiskit activate batch job submission support, so if you are not using these versions, upgrading might help:
Hi @josh, thanks for the prompt reply. I was indeed using v19 and v18 for pennylane and pennylane-qiskit. However, when I check the call function in pennylane/qnn/keras.py I can still see that the code actually unstacks the input batch and submits the jobs one by one. Is batching only supported for PennyLane but not for its keras application?
Hi, @josh I have an additional question. I was testing my circuit with @qml.batch_params to see how this works. So by default it takes inputs (non-trainable) of (n_batch, n_qubit) and weights (trainable) (n_weights, n_batch) and when I set @qml.batch_params(all_operations=False) it only accepts batched trainables. This is a bit counter-intuitive to me because in a regular ML application I would batch the inputs (non-trainable) and run them through my network with the same weights and then take the derivative according to the mean or sum loss etc. Is there something that I’m missing that is special for quantum applications? Or is there a similar implementation that I’m not aware of?
Good catch! Indeed, it looks like the Keras layer needs to be updated to support batch execution.
Would you mind opening an issue over at the PennyLane GitHub repository, here? This will help bring it to the development teams attention
Is there something that I’m missing that is special for quantum applications? Or is there a similar implementation that I’m not aware of?
@jackaraz you are not missing anything, I think that is a pretty good overview! The @qml.batch_params decorator is a recent addition to PL, so any insights to your workflow, or changes that will be helpful, are super appreciated.
In particular, if you have any pseudo-code examples showing how you would like it to work, that would be great!