Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PytorchModel work with quantum circuits #143

Open
dimkart opened this issue May 7, 2024 · 1 comment
Open

Make PytorchModel work with quantum circuits #143

dimkart opened this issue May 7, 2024 · 1 comment
Assignees
Labels
up-for-grabs Available to external contributors

Comments

@dimkart
Copy link
Contributor

dimkart commented May 7, 2024

Description

lambeq provides a large number of models and trainers, covering a broad range of use cases, both quantum and "classical", where the latter models operate on tensor networks. Currently, the PytorchModel works exclusively on tensor networks, hence it is relevant only for "classical" experiments.

This task asks for the extension of PytorchModel so it could also work with quantum circuits, in the same way as e.g. the PennyLaneModel does. This will allow quantum models to be trained using gradient-based optimisers such as Adam. The following changes will need to be made.

  • In quantum ansatze, the lambeq symbols will need to be used instead of sympy symbols directly.
  • The initialise_weights method will need to know whether it is operating on a quantum circuit or tensor network, and the quantum circuit weights may be initialised uniformly at random, without the current logic used for tensors.
  • Some additional changes may be needed to the quantum backend to ensure that gradients are calculated appropriately by pytorch's autograd.
  • An example notebook demonstrating the new capability will need to be demonstrated. This can simply use the classical pipeline example notebook, and replace the ansatz with a quantum ansatz.

Notes

  • Adding the functionality in a new class QuantumPytorchModel, instead of extending the PytorchModel class, might be an acceptable alternative.
  • Include in the PR the results of a basic test run as a proof of concept, training one of the lambeq datasets with the new model.

References

@neiljdo neiljdo added the unitaryHACK2024 Tasks for unitaryHACK 2024 label May 28, 2024
@neiljdo neiljdo changed the title Make PytorchModel work with quantum circuits [unitaryHACK 2024] Make PytorchModel work with quantum circuits May 28, 2024
@Vikrant-Khedkar
Copy link

hey up for this

@dimkart dimkart changed the title [unitaryHACK 2024] Make PytorchModel work with quantum circuits Make PytorchModel work with quantum circuits Jul 30, 2024
@dimkart dimkart added up-for-grabs Available to external contributors and removed unitaryHACK2024 Tasks for unitaryHACK 2024 labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
up-for-grabs Available to external contributors
Projects
None yet
Development

No branches or pull requests

4 participants