However, I saw that GPU utilization is low, and the code is faster on the CPU than on the GPU . Here is a scene shot of the first few iterations with some settings:
You’re using 4 qubits, so in this regime using CPU will always be faster than using GPUs. There are computation overheads when using GPUs so for small circuits it’s not worth it. Check the Performance section of the PennyLane website, where we describe where one simulator or the other works best.
On the other hand, I didn’t see lightning.gpu or lightning.kokkos as installed devices. Your quantum circuit may not be running on GPUs after all. Find how to install them in the Install section of the PennyLane website. Note that for lightning.gpu you will need an NVIDIA GPU with Volta or Ampere architecture.
Finally, you’re using a very old version of PennyLane. The current supported version is v0.40, while you’re using v0.29. Use python -m pip install pennylane --upgrade to upgrade to the latest version.
Thanks for your insights! I wanted to clarify a couple of things:
The code is slow even with just 2 qumodes and a cutoff_dim of 3 because I am using a batch size of 64 and running the circuit for each batch sample. Using a large number of qumodes is inherently prohibitive with CV quantum simulations.
I am using an older version of PennyLane because I am implementing a continuous variable quantum neural network (CVQNN) based on the approach described in this reference. After testing different configurations, the combination of libraries shown in pennylane.about() is the only one that works reliably for my implementation.
I’d really appreciate it if you could provide an example or any guidance on how to implement a CVQNN using the newer version of PennyLane.
I didn’t realize you were using the PennyLane-SF plugin. Unfortunately the plugin is not supported in newer versions of PennyLane so you do need to use v0.29 of PennyLane.
For working with CV quantum computing I’d actually recommend MrMustard instead of Strawberry Fields. Unfortunately it’s not compatible with PennyLane but it does allow for optimization, as you can see at the end of the API reference.
I’m not sure if this is what you were looking for, but it might help you if you’re interested specifically in CV.