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

Wrapping of legacy device automatically in various device creation/qnode/execute functions #6046

Merged
merged 117 commits into from
Aug 21, 2024

Conversation

Shiro-Raven
Copy link
Contributor

Context:
With the LegacyDeviceFacade now in place, we can add automatic wrapping of legacy devices.

Description of the Change:
Add automatic wrapping to qml.device, qml.execute, QNode constructor, and the get_best_method and best_method_str functions of the QNode class. The tests are also updated accordingly.

Benefits:
Users no longer need to worry about upgrading their devices to the new Device API and can use the facade to access the basic functions of the new API.

Possible Drawbacks:
The facade doesn't yet provide all potential advantages of fully upgrading to the new API

[sc-65998]

albi3ro and others added 30 commits April 1, 2024 16:50
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
pennylane/devices/legacy_facade.py Show resolved Hide resolved
pennylane/devices/legacy_facade.py Outdated Show resolved Hide resolved
pennylane/devices/tests/conftest.py Show resolved Hide resolved
pennylane/devices/tests/test_measurements.py Show resolved Hide resolved
pennylane/transforms/core/transform_dispatcher.py Outdated Show resolved Hide resolved
pennylane/workflow/execution.py Show resolved Hide resolved
pennylane/workflow/execution.py Show resolved Hide resolved
pennylane/workflow/execution.py Show resolved Hide resolved
pennylane/workflow/qnode.py Show resolved Hide resolved
pennylane/workflow/qnode.py Show resolved Hide resolved
Copy link
Contributor

@astralcai astralcai left a comment

Choose a reason for hiding this comment

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

LGTM! Impressive work! 🚀

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Finally getting this across the finish line! Thanks for the changes and for the dev comments.

Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Fantastic job on a rather difficult piece of work. I am excited to have finally reached this threshold in a very, very long process. This is going to make development of the workflow much easier going forward, and unlock a lot of technical improvements and code quality possibilities.

@Shiro-Raven Shiro-Raven merged commit 1f55c88 into master Aug 21, 2024
40 checks passed
@Shiro-Raven Shiro-Raven deleted the ad/facade-wrapper branch August 21, 2024 02:59
Shiro-Raven added a commit to PennyLaneAI/pennylane-lightning that referenced this pull request Aug 21, 2024
…ots (#839)

**Context:**
PR PennyLaneAI/pennylane#6046 wraps the legacy
device API automatically in various device creation, qnode, and execute
functions. As LK and LGPU plugins still rely on the legacy device API,
the shots tests and the `generate_samples` logic in
`lightning_kokkos.py` and `lightning_gpu.py` should be updated to adhere
the new convention.

**Related Shortcut Stories:**
[sc-65998]

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Co-authored-by: Shiro-Raven <exclass9.24@gmail.com>
Co-authored-by: albi3ro <chrissie.c.l@gmail.com>
multiphaseCFD pushed a commit to PennyLaneAI/pennylane-lightning that referenced this pull request Aug 21, 2024
…ots (#839)

**Context:**
PR PennyLaneAI/pennylane#6046 wraps the legacy
device API automatically in various device creation, qnode, and execute
functions. As LK and LGPU plugins still rely on the legacy device API,
the shots tests and the `generate_samples` logic in
`lightning_kokkos.py` and `lightning_gpu.py` should be updated to adhere
the new convention.

**Related Shortcut Stories:**
[sc-65998]

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Co-authored-by: Shiro-Raven <exclass9.24@gmail.com>
Co-authored-by: albi3ro <chrissie.c.l@gmail.com>
maliasadi added a commit to PennyLaneAI/pennylane-lightning that referenced this pull request Aug 22, 2024
…legacy device for MPI LGPU (#864)

### 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`.

- [x] 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:**

- PR PennyLaneAI/pennylane#6021 removed code
duplication for `BasisEmbedding` and `BasisState`. As the result
`BasisState` no longer decomposes to `BasisStatePreparation`. This PR
updates Python unit tests to support this generalization of basis state
preparation.

- PR PennyLaneAI/pennylane#6046 added a facade
wrapper class for "legacy" devices. This PR is a follow up to PR #839
updating Multi-GPU LGPU device and tests.

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
mehrdad2m added a commit to PennyLaneAI/catalyst that referenced this pull request Aug 26, 2024
…acade (#1035)

**Context:**
This PR is to fix an issue that will be caused after merging the
following PR:
PennyLaneAI/pennylane#6046

The problem is that LegacyDeviceFacade will cause the Legacy Devices to
use the Shots class instead of an integer which causes a crash in
runtime.

**Description of the Change:**
This PR ensures that the any device that is an instance of the new
device API uses the shots class to extract the total number of shots.

**Related GitHub Issues:**
[sc-70792]

---------

Co-authored-by: Ahmed Darwish <exclass9.24@gmail.com>
multiphaseCFD pushed a commit to PennyLaneAI/pennylane-lightning that referenced this pull request Sep 8, 2024
…ots (#839)

**Context:**
PR PennyLaneAI/pennylane#6046 wraps the legacy
device API automatically in various device creation, qnode, and execute
functions. As LK and LGPU plugins still rely on the legacy device API,
the shots tests and the `generate_samples` logic in
`lightning_kokkos.py` and `lightning_gpu.py` should be updated to adhere
the new convention.

**Related Shortcut Stories:**
[sc-65998]

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Co-authored-by: Shiro-Raven <exclass9.24@gmail.com>
Co-authored-by: albi3ro <chrissie.c.l@gmail.com>
multiphaseCFD pushed a commit to PennyLaneAI/pennylane-lightning that referenced this pull request Sep 8, 2024
…legacy device for MPI LGPU (#864)

### 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`.

- [x] 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:**

- PR PennyLaneAI/pennylane#6021 removed code
duplication for `BasisEmbedding` and `BasisState`. As the result
`BasisState` no longer decomposes to `BasisStatePreparation`. This PR
updates Python unit tests to support this generalization of basis state
preparation.

- PR PennyLaneAI/pennylane#6046 added a facade
wrapper class for "legacy" devices. This PR is a follow up to PR #839
updating Multi-GPU LGPU device and tests.

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
mudit2812 added a commit that referenced this pull request Sep 10, 2024
…ode/execute functions (#6046)

**Context:**
With the `LegacyDeviceFacade` now in place, we can add automatic
wrapping of legacy devices.

**Description of the Change:**
Add automatic wrapping to `qml.device`, `qml.execute`, `QNode`
constructor, and the `get_best_method` and `best_method_str` functions
of the QNode class. The tests are also updated accordingly.

**Benefits:**
Users no longer need to worry about upgrading their devices to the new
Device API and can use the facade to access the basic functions of the
new API.

**Possible Drawbacks:**
The facade doesn't yet provide all potential advantages of fully
upgrading to the new API

[[sc-65998](https://app.shortcut.com/xanaduai/story/65998)]

---------

Co-authored-by: albi3ro <chrissie.c.l@gmail.com>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Korbinian Kottmann <43949391+Qottmann@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants