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

Add tag dispatch for memory location with LQ classes #492

Merged
merged 7 commits into from
Sep 1, 2023
Merged

Conversation

mlxd
Copy link
Member

@mlxd mlxd commented Aug 30, 2023

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: To allow selection of supports for both internally and externally managed memory, enabling a class attribute to be accessed indicating where memory lives is necessary. To better support lightning's classes, and their extensions, this PR adds struct tags to each statevector class in the lightning.qubit tree. Struct tags are prefered here over enums as they can be used for compile-time selections, and such we make use of this now in a safer way under the adjoint gradient pipeline.

Description of the Change: As above.

Benefits: Allows compile-time decisions and support checking of memory ownership in lightning.qubit associated statevector classes.

Possible Drawbacks:

Related GitHub Issues:

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@mlxd mlxd marked this pull request as ready for review August 30, 2023 17:15
@mlxd mlxd requested review from AmintorDusko and maliasadi August 30, 2023 17:21
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.47% ⚠️

Comparison is base (824fd77) 96.84% compared to head (42d5b7d) 96.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #492      +/-   ##
==========================================
- Coverage   96.84%   96.37%   -0.47%     
==========================================
  Files         142       23     -119     
  Lines       16278     1186   -15092     
==========================================
- Hits        15764     1143   -14621     
+ Misses        514       43     -471     
Files Changed Coverage Δ
pennylane_lightning/core/src/utils/Memory.hpp 55.55% <ø> (-34.77%) ⬇️
pennylane_lightning/core/src/utils/Util.hpp 100.00% <ø> (+2.41%) ⬆️
pennylane_lightning/core/_version.py 100.00% <100.00%> (ø)

... and 129 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Nice implementation.
This will, for sure, address my comment on PR 482.
Happy to approve when we move the MemoryStorageLocation namespace to a more suitable header.

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 @mlxd! It solves the issue with registering StateVectorLQubitDynamic in our end too.

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.

Thank you for that!

@mlxd mlxd merged commit 869bbb8 into master Sep 1, 2023
@mlxd mlxd deleted the add_memory_tag branch September 1, 2023 16:34
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.

3 participants