PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.3k stars 592 forks source link

backprop diff method for torch interface #931

Closed shukob closed 3 years ago

shukob commented 3 years ago

Issue description

I would like to create an end-to-end differentiable (w.r.t. quantum state vector) device using PyTorch to make it work with the torch interface. Is it currently possible using the TF/Autograd backend? or do we have to create a separate one for PyTorch? I have a CUDA compatibility issue if I include both torch and tensorflow in the same conda env, so I could not try that. autograd device with backprop does not work with torch interface. If a separate device is required, seeing the implementation of default.qubit.tf, it seems easy to create another one. I will work on it or will build one as a separate private project if it is not suitable to be included as default.qubit family.

josh146 commented 3 years ago

Hi @shukob! Just yesterday, @iamlucaswolf began working on a PyTorch version of default.qubit, available here: #929

It's still work in progress, but feel free to give it a go, and let us know if you have any comments or suggestions 🙂

shukob commented 3 years ago

@josh146 Thank you! That is great! I will check that work!

iamlucaswolf commented 3 years ago

@shukob Please do so. Sampling is still an issue that we're working on, but differentiating measurement statistics should already work on CUDA devices. I'd be very interested in your feedback!

shukob commented 3 years ago

@iamlucaswolf Thank you! I will checkout the branch and try!

mariaschuld commented 3 years ago

Closing this due to inactivity, feel free to reopen if necessary.