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

pytorch backend #1202

Merged
merged 144 commits into from
Mar 14, 2024
Merged

pytorch backend #1202

merged 144 commits into from
Mar 14, 2024

Conversation

Simone-Bordoni
Copy link
Contributor

@Simone-Bordoni Simone-Bordoni commented Feb 8, 2024

Backend based on pytorch for optimised automatic differentiation.

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.

@Simone-Bordoni Simone-Bordoni self-assigned this Feb 8, 2024
@Simone-Bordoni Simone-Bordoni added the enhancement New feature or request label Feb 8, 2024
@Simone-Bordoni Simone-Bordoni linked an issue Feb 8, 2024 that may be closed by this pull request
@Simone-Bordoni
Copy link
Contributor Author

I need a bit of help to finish this work.
For now i have created the pytorch backend starting from the tf backend and basically replacing all tf functions/tensors with torch functions/tensors.
Where can I add the tests of the code?
What else do i have to change to make everything work?
Where can i write the documentation of the backend?
I get a pylint error when using torch.linalg.eigvalsh, torch.linalg.eigh, torch.linalg.matrix_exp, torch.sparse.mm (not-callable error) for now i have disabled this error on pylint, however i can't find a similar error and I don't know if there is a way to solve it without disabling the pylint error.

@renatomello renatomello added this to the Qibo 0.2.5 milestone Feb 8, 2024
Copy link
Member

@scarrazza scarrazza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Simone-Bordoni for this. Could you please include pytorch in tests by updating this file and check coverage?

@renatomello renatomello marked this pull request as draft February 9, 2024 10:55
@renatomello
Copy link
Contributor

renatomello commented Feb 9, 2024

I converted this PR to draft just because it's gonna take a little bit to finish it

@Simone-Bordoni
Copy link
Contributor Author

I converted this PR to draft just because it's gonna take a little bit to finish it

I thought it would have been an easy thing but there are many parts of qibo that are not backend agnostic and struggle with pytorch.

@Simone-Bordoni
Copy link
Contributor Author

It doesn’t change every time. It’s always the same dict on CI, but it’s a different duct when the test is run locally

Ok, now it makes sense. sorry if i changed it again, i will not touch it anymore

@Simone-Bordoni
Copy link
Contributor Author

I have reverted the changes to the test with seed so now everything should pass. Thanks to @BrunoLiegiBastonLiegi I also managed to remove some more unuseful methods in the pytorch backend.

@renatomello renatomello linked an issue Mar 14, 2024 that may be closed by this pull request
Copy link
Contributor

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Simone-Bordoni, please address these last minor things and open an issue about adding support to gradients in the pytorch backend. Then we can merge this I guess.

src/qibo/backends/numpy.py Outdated Show resolved Hide resolved
src/qibo/backends/numpy.py Outdated Show resolved Hide resolved
tests/test_hamiltonians.py Outdated Show resolved Hide resolved
tests/test_backends_clifford.py Outdated Show resolved Hide resolved
tests/test_gates_gates.py Show resolved Hide resolved
tests/test_hamiltonians.py Outdated Show resolved Hide resolved
tests/test_hamiltonians.py Outdated Show resolved Hide resolved
This was unlinked from issues Mar 14, 2024
@renatomello renatomello added this pull request to the merge queue Mar 14, 2024
Merged via the queue into master with commit 3474d5e Mar 14, 2024
20 of 21 checks passed
@renatomello renatomello deleted the pytorch_backend branch March 14, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants