Thanks a lot for your help, it worked after I put tf.keras.backend.set_floatx('float64') on the line after import tensorflow as tf. But trying to use diff_method=‘adjoint’ runs slower.
I added some samples for training. Running an epoch with diff_method='backprop' is about 1598s and diff_method=‘backprop’ seems to take 1:27:29
In addition, the output information of qml.about() is as follows:
Usually the fastest combination is using lightning.qubit as your device and diff_method='adjoint'.
I also see that you have a relatively old version of PennyLane. You can upgrade to the latest version of PennyLane by using python -m pip install pennylane --upgrade
We will release a new version on Tuesday so you may want to wait until then, although some parts of your code may break because of any breaking changes that may have introduced in the past few releases.
Thank you for your help, when I try to run an epoch with diff_method=‘adjoint’ the time is about 28min
The time for diff_method=‘backprop’ is also about 28 minutes.
Hi @Cc1,
Unfortunately if you already use lightning.qubit as your device and diff_method='adjoint' then it will be hard to reduce your execution time. Your problem just may be too large.
You can try reducing the number of qubits needed or changing from using StronglyEntanglingLayers to a different ansatz. This may lower the execution time but it may also lower your accuracy.
Please let me know if you have any further questions about this.
I hope you can find a way to optimize your model. You can also try using a different interface, so using JAX and JIT instead of TensorFlow. This may require a lot of work though or it may not be possible in your particular case.
Please let us know if you have any further questions.
Thank you for your reply. I noticed that “lightning.gpu” can be used for acceleration. But when I try to install I get some errors. Does “lightning.gpu” only work under Linux?
If it can only run under linux system, then I may use lightning, but I don’t know how lightning calls more threads? Because I found that when I run my tasks, the CPU and memory usage is not very high.