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 build-time flag to enable OpenMP in Lightning gate kernels #510

Merged
merged 29 commits into from
Jan 12, 2024
Merged

Conversation

mlxd
Copy link
Member

@mlxd mlxd commented Oct 3, 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: The default threading behaviour for lightning.qubit is to assume single threaded execution at the gate level, but allow multi-threaded execution over observables with the adjoint differentiation pipeline. This allows us to always ensure the best (SIMD) gate kernel performance, but limits the performance for situations with deep circuits on large CPUs (high core count, and big caches). This PR adds a compile-time flag, defaulting to off, to allow lightning.qubit to add OpenMP supports to all kernels (LM, AVX2, and AVX512). this will allow for better performance tuning on HPC systems, while preserving the default behavior during release.

Description of the Change: As above. Option enabled through a LQ_ENABLE_KERNEL_OMP CMake option in the LQ backend, which is default disabled.
Benefits: Allows better performance tuning on HPC systems.

Possible Drawbacks: If on by default, OMP overhead may slow down small circuits. Testing on CI will show no benefit (1 physical core only), so no additional tests added.

Related GitHub Issues:

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (df43949) 98.18% compared to head (ed91025) 98.67%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #510      +/-   ##
==========================================
+ Coverage   98.18%   98.67%   +0.48%     
==========================================
  Files          10      169     +159     
  Lines        1210    24308   +23098     
==========================================
+ Hits         1188    23985   +22797     
- Misses         22      323     +301     

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

@mlxd mlxd marked this pull request as ready for review October 4, 2023 14:19
@mlxd mlxd requested a review from a team October 4, 2023 14:22
mlxd added a commit that referenced this pull request Dec 11, 2023
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! LGTM 🎉 I have a few questions regarding the support, but there is nothing major to address from my side.

@mlxd mlxd requested review from a team, vincentmr and maliasadi January 12, 2024 19:51
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.

LGTM!

.github/CHANGELOG.md 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.

🪂

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 @mlxd for the nice work!

@mlxd
Copy link
Member Author

mlxd commented Jan 12, 2024

Thanks for all of the comments folks!

@mlxd mlxd merged commit ac8795d into master Jan 12, 2024
84 checks passed
@mlxd mlxd deleted the kernel_omp branch January 12, 2024 22:48
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.

5 participants