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

Migration of lightning.gpu device to the new device API #853

Merged
merged 271 commits into from
Oct 3, 2024

Conversation

LuisAlfredoNu
Copy link
Contributor

@LuisAlfredoNu LuisAlfredoNu commented Aug 14, 2024

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 and Lightning Kokkos that use the New Device API, we can now migrate Lightning GPU device to the new device API.

Description of the Change:
Migration of Lightning GPU with MPI support to integrate the New device API. The list of main feature changes are

  • Add the MPIHandler state_vector, measurements, and adjoint-jacobian classes for lightning.gpu.
  • Add the simulate, jacobian, simulate_and_jacobian, vjp, and simulate_and_vjp methods to lighting.gpu.
  • Add MPI support to lightning.gpu with the New device API.
  • Update unit/integration tests for the new device API to work with lightning.gpu
  • Check the full support for sampling in full parity with Lightning Qubit
  • Replace the old device API for Lightning GPU.

Benefits:
Full integration of Lightning GPU with the new device API.

Possible Drawbacks:

Related GitHub Issues:

[sc-70964] [sc-59219]

LuisAlfredoNu and others added 30 commits July 26, 2024 14:24
### 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]>
### 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 'jacobian' and vjp` methods are necessary to achieve full
functionality with the new device API.
We are going to follow the same recipe used with LightningQubit.

**Benefits:**
Add two 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 on the following lines in .github/workflows
files

```bash
: # 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 merging to master

[sc-68808] [sc-68814]

---------

Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
…836)

### 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:**
Add the necessary method for the LightningKokkos that allows the use of
new device API. It should have a similar structure as the LightningQubit
class.

Note: Lightning Kokkos does not support MCMC sampling.

**Benefits:**
Integration of LighntingKokkos with the new device API.

**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 on the following lines in .github/workflows
files

```
: # 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 merging to master

[sc-68820]

---------

Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
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:**
Unlock and modify all the unit tests for `Lightning Kokkos` and pass all
the CI.

**Benefits:**
Integration of LighntingKokkos with the new device API.

**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 on the following lines in .github/workflows
files

```
: # 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 merging to master


[sc-68823]

---------

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

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

Another round

mpitests/test_apply.py Outdated Show resolved Hide resolved
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.

LGTM! 🥇 happy to approve the PR right after addressing a few more minor suggestions, knowing that we will have several follow-up PRs in the future to further improve the code quality of this device.

Makefile Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_probs.py Show resolved Hide resolved
mpitests/test_expval.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Show resolved Hide resolved
mpitests/test_apply.py Outdated Show resolved Hide resolved
Copy link
Member

@multiphaseCFD multiphaseCFD 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 . Just a few more Qs.

mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
mpitests/test_adjoint_jacobian.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_measurements_class.py Outdated Show resolved Hide resolved
tests/new_api/test_device.py Show resolved Hide resolved
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.

🪂

Copy link
Member

@multiphaseCFD multiphaseCFD 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 for the nice and hard work!

@LuisAlfredoNu LuisAlfredoNu merged commit 133ab15 into master Oct 3, 2024
105 of 106 checks passed
@LuisAlfredoNu LuisAlfredoNu deleted the gpuNewAPI_backend branch October 3, 2024 13:10
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. ci:use-gpu-runner Enable usage of GPU runner for this Pull Request ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request do not merge Do not merge PR until this label is removed urgent Mark a pull request as high priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants