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 C++ decomposition with scipy_openblas32 #995

Merged
merged 182 commits into from
Dec 4, 2024
Merged

Conversation

multiphaseCFD
Copy link
Member

@multiphaseCFD multiphaseCFD commented Nov 12, 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:

[sc-78187] & [sc-53754]

The blas/lapack support is a long standing issue for lightning. The main challenge is the wheels building for the windows platform, which does not support a fortran compiler natively. Recently, the scipy team release the standalone scipy-openblas32 wheel for linux, windows and macos platform. This could solve the win support issue.

There are a few technical discussions on how to add the scipy-openblas32 support to lightning:

  • Dynamic loading vs static linking? Dynamic loading was chosen and the relative path to the libscipy_openblas is added to the runpath of the shared lib object of installations from wheel. In this case, scipy-openblas32 is required to be installed in the same site-packages dir. However, for the direct C++ usage as well as pip editable install, the absolute path to libscipy_openblas is still needed to ensure the libscipy_openblas lib can be found and loaded.
  • As a result, scipy-openblas32 is a dependency of lightning.
  • This implementation does not support conda-forge.

This PR also brings a few other changes:

  • BLASLib loading is handled by a singleton class BLASLibLoaderManager, instead of the compute_diagonalizing_gates API.
  • The openblas support is tested against macos, linux and windows for the C++ tests on CIs and integration with catalyst locally.
  • An additional cmake option: PY_INSTALL is added to identify if the pip installation is editable or not. This PY_INSTALL is ON if not self.editable_mode.

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:

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.

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.20%. Comparing base (f9e8f62) to head (4342619).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
..._lightning/core/src/utils/BLASLibLoaderManager.hpp 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #995      +/-   ##
==========================================
- Coverage   94.44%   92.20%   -2.24%     
==========================================
  Files         229      178      -51     
  Lines       38841    27390   -11451     
==========================================
- Hits        36682    25254   -11428     
+ Misses       2159     2136      -23     

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

@multiphaseCFD multiphaseCFD marked this pull request as ready for review November 12, 2024 23:05
@multiphaseCFD multiphaseCFD changed the title Add decomposition with scipy_openblas32 [WIP] Add decomposition with scipy_openblas32 Nov 12, 2024
@multiphaseCFD multiphaseCFD requested review from josephleekl and a team and removed request for josephleekl December 2, 2024 17:02
setup.py Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@josephleekl
Copy link
Contributor

awesome work @multiphaseCFD ! Just added some comments/questions, happy to look over it again and approve once answered!

@josephleekl
Copy link
Contributor

also have you updated the changelog?

Copy link
Contributor

@LuisAlfredoNu LuisAlfredoNu 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 @multiphaseCFD
Only a couple of comments 👍

CMakeLists.txt Show resolved Hide resolved
requirements-dev.txt 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 after addressing the last round of concerns and suggestions.

Makefile Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
requirements-dev.txt Outdated Show resolved Hide resolved
scripts/configure_pyproject_toml.py Outdated Show resolved Hide resolved
setup.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.

Thanks @multiphaseCFD! 🎉

Copy link
Contributor

@josephleekl josephleekl left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @multiphaseCFD for this addition!

@multiphaseCFD multiphaseCFD merged commit 705fe89 into master Dec 4, 2024
111 of 112 checks passed
@multiphaseCFD multiphaseCFD deleted the add_scipy_openblas branch December 4, 2024 22:17
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. urgent Mark a pull request as high priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants