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

Unify Lightning Kokkos device and Lightning Qubit device under a Lightning Base device #876

Merged
merged 171 commits into from
Sep 9, 2024

Conversation

LuisAlfredoNu
Copy link
Contributor

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    tests directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the .github/CHANGELOG.md file, summarizing the
    change, and including a link back to the PR.

  • Ensure that code is properly formatted by running make format.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
Following the design of *Lightning Qubit uses the New Device API end to end, we can now migrate lightning.kokkos device to the new device API.

Description of the Change:
Increase the reusability of the code by creating base classes for Lightning StateVector, Measurements, and AjointJacobian. Create a new device base class for LightningQubit and LightningKokkos.

Benefits:
Improve the maintenance and readability of the Python front-end devices for LQ and LK.

Possible Drawbacks:

Related GitHub Issues:

[sc-71783]

LuisAlfredoNu and others added 30 commits July 22, 2024 16:43
Co-authored-by: Amintor Dusko <[email protected]>
### Before submitting

Please complete the following checklist when submitting a PR:

- [X] All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to
the
      [`tests`](../tests) directory!

- [X] All new functions and code must be clearly commented and
documented.
If you do make documentation changes, make sure that the docs build and
      render correctly by running `make docs`.

- [X] Ensure that the test suite passes, by running `make test`.

- [ ] Add a new entry to the `.github/CHANGELOG.md` file, summarizing
the
      change, and including a link back to the PR.

- [X] Ensure that code is properly formatted by running `make format`. 

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


------------------------------------------------------------------------------------------------------------

**Context:**
Migrate the lightning.kokkos device to the new device API.

**Description of the Change:**
The 'simulate' method is necessary to achieve full functionality with
the new device API.
We are going to follow the same recipe used with LightningQubit.

**Benefits:**
Add one of the essential methods for the new device API into
LightningKokkos.

**Possible Drawbacks:**

**Related GitHub Issues:**
## Partial / Freezzed PR ⚠️ ❄️

To make a smooth integration of LightningKokkos with the new device API,
we set the branch `kokkosNewAPI_backend` as the base branch target for
this development.

The branch `kokkosNewAPI_backend` has the mock of all classes and
methods necessary for the new API. Also, several tests were disabled
with

``` python
if device_name == "lightning.kokkos":
    pytest.skip("Kokkos new API in WIP.  Skipping.",allow_module_level=True)
```

Additionally, the CI testing from PennyLane for LKokkos is temporally
disabled through commenting the following lines in `.github/workflows`
files
``` yml
: # pl-device-test --device ${DEVICENAME} --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
: # pl-device-test --device ${DEVICENAME} --shots=None --skip-ops $COVERAGE_FLAGS --cov-append
```

However, these tests will unblocked as the implementation progresses.

After all the developments for integrating LightningKokkos with the new
API have been completed then the PR will be open to merge to master

[sc-68801]

---------

Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

Looks pretty good! It needs a few adjustments, though. Could you re-tag me when done and I will give you one more look? Thanks!

Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

I had a second pass over the code... Thanks @LuisAlfredoNu for addressing my first round of review comments by using abc & better practices for writing base 'abstract' classes in Python 💯 However, I am afraid there are still a few more things to fix 🚀

Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

Nice work @LuisAlfredoNu , I love the code reduction! A few suggestions, but otherwise LGTM.

@LuisAlfredoNu
Copy link
Contributor Author

@AmintorDusko All the suggestions are done or commented on. Could you make a second review, please? 😄

Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Thanks @LuisAlfredoNu 🥳 Please wait for @ringo-but-quantum to autoupdate the version before merging the PR

Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

Great job! Thank you for that!

@LuisAlfredoNu LuisAlfredoNu merged commit 89a1bed into master Sep 9, 2024
96 of 98 checks passed
@LuisAlfredoNu LuisAlfredoNu deleted the kokkosNewAPI_unify branch September 9, 2024 15:14
@LuisAlfredoNu LuisAlfredoNu restored the kokkosNewAPI_unify branch September 10, 2024 22:47
@LuisAlfredoNu LuisAlfredoNu deleted the kokkosNewAPI_unify branch September 10, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:build_wheels Activate wheel building.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants