-
Notifications
You must be signed in to change notification settings - Fork 39
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
Optimize LM controlled kernels [sc-73461] #882
Conversation
Co-authored-by: Luis Alfredo Nuñez Meneses <alfredo.nunez@xanadu.ai>
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #882 +/- ##
==========================================
- Coverage 96.23% 94.52% -1.72%
==========================================
Files 212 168 -44
Lines 28318 21134 -7184
==========================================
- Hits 27252 19977 -7275
- Misses 1066 1157 +91 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vincentmr! Just a few minor comments but happy to approve after resolving them.
pennylane_lightning/core/src/simulators/lightning_qubit/gates/GateIndices.cpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/gates/GateIndices.cpp
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @vincentmr. I have a few comments and questions. Do you have some quick data about the performance of this implementation? 🚀
pennylane_lightning/core/src/simulators/lightning_qubit/gates/GateIndices.cpp
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/gates/GateIndices.cpp
Outdated
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Outdated
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vincentmr for the nice work! LGTM!
pennylane_lightning/core/src/simulators/lightning_qubit/gates/GateIndices.cpp
Show resolved
Hide resolved
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the nice work, @vincentmr !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice optimization and good performance improvement. Thank you @vincentmr
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 thechange, 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:
As a first step toward adding controls in Lightning Kokkos kernels, the controlled Lightning Qubit kernels are simplified.
Description of the Change:
controlBitPatterns
, the controlled version ofgenerateBitPatterns
, and remove obsoleteparity2indices
implementations.core_function
signature from coefficients & indices to indices & offset.Benefits:
indices
are now precomputed (thereby saving time) and only offset needs be updated on the fly.omp parallel for
loops are now free of private arguments.We illustrate the performance improvement running the XAS workflow from the benchmark suite. This workflow has a circuit with the following specs
and a bottleneck is applying the 9000
C(MultiRZ)
gates. With v0.38.0 we get (zooming onsimulate_and_jacobian
with SnakeViz)and for the current PR
We get a 6.6x speed-up on the
C(MultiRZ)
gates.Possible Drawbacks:
Related GitHub Issues: