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

Prevent reallocation of aligned memory #572

Merged
merged 28 commits into from
Jan 4, 2024
Merged

Prevent reallocation of aligned memory #572

merged 28 commits into from
Jan 4, 2024

Conversation

mlxd
Copy link
Member

@mlxd mlxd commented Dec 7, 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 ensure the memory allocated by Lightning is always aligned, and usable by the dispatcher AVX kernels, we must avoid any potential numpy-layer reallocations. This PR extends the aligned allocator functions bound through Pybind11 to allow data to be initialized and set for use. This avoids us needing to perform potential numpy casts, which could potentially reallocate the data. As a result, this removes overheads observed with lightning.qubit workloads depending on the need to handle multiple resets/allocations.

Description of the Change: As above.

Benefits: Removes unneeded overheads from lightning.qubit, and redundant imports from LG/LK

Possible Drawbacks:

Related GitHub Issues:

Copy link
Contributor

github-actions bot commented Dec 7, 2023

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.

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (dfad9d7) 98.48% compared to head (70e5b28) 99.06%.

Files Patch % Lines
pennylane_lightning/core/src/utils/Memory.hpp 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #572      +/-   ##
==========================================
+ Coverage   98.48%   99.06%   +0.57%     
==========================================
  Files         167      201      +34     
  Lines       24531    29361    +4830     
==========================================
+ Hits        24159    29086    +4927     
+ Misses        372      275      -97     

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

@mlxd mlxd added the ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request label Dec 8, 2023
@mlxd mlxd marked this pull request as ready for review December 12, 2023 19:06
@mlxd mlxd requested a review from maliasadi January 3, 2024 22:13
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! Looks good to go 🦖

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.

Looks good to me! Thanks @mlxd !

@mlxd mlxd merged commit 3c648f7 into master Jan 4, 2024
@mlxd mlxd deleted the improve_lq_memory branch January 4, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants