-
Notifications
You must be signed in to change notification settings - Fork 35
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 native PauliRot implementation in LightningQubit #834
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #834 +/- ##
==========================================
- Coverage 95.17% 92.39% -2.79%
==========================================
Files 113 70 -43
Lines 18141 11250 -6891
==========================================
- Hits 17265 10394 -6871
+ Misses 876 856 -20 ☔ View full report in Codecov by Sentry. |
...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
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/gates/GateIndices.cpp
Outdated
Show resolved
Hide resolved
### 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`](../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`. - [x] 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:** @mlxd [mentioned](#834 (comment)) that "the use of structured bindings/lambdas when combined with OpenMP often fails to compile with clang due to missing support" **Description of the Change:** Replace structured bindings by variables in `GateImplementationsLM.hpp`. **Benefits:** Compile with Clang & OpenMP. **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
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.
Thank @vincentmr! Nice work! Just a few comments.
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
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
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
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_qubit/StateVectorLQubit.hpp
Outdated
Show resolved
Hide resolved
…ectorLQubit.hpp Co-authored-by: Luis Alfredo Nuñez Meneses <alfredo.nunez@xanadu.ai>
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 just a couple of comments 🚀
...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
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
…cpu_kernels/GateImplementationsLM.hpp Co-authored-by: Luis Alfredo Nuñez Meneses <alfredo.nunez@xanadu.ai>
...ne_lightning/core/src/simulators/lightning_qubit/gates/cpu_kernels/GateImplementationsLM.hpp
Outdated
Show resolved
Hide resolved
…cpu_kernels/GateImplementationsLM.hpp Co-authored-by: Luis Alfredo Nuñez Meneses <alfredo.nunez@xanadu.ai>
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 @vincentmr for the nice work.
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 and good improvement for Pauli Rotations 👍
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:
Pauli rotations come up in many places, and importantly in the time evolution of qchem Hamiltonians. It is therefore worth considering ways to accelerate their execution.
Description of the Change:
Implement
applyPauliRot
in the LM gate kernel. InvokeapplyPauliRot
directly from the SV class and add bindings to the Python layer. Add custom decomposition rule forPauliRot
operations.Benefits:
Faster Pauli rotations. I performed a benchmark on random
PauliRotation
s (runtime > 1.0 sec and at least 5 of them) through the Python layer. The data remains noisy with 5 samples because the performance varies depending on the specific "XYZ" sequence (which translates into more or less predictable memory access patterns). Overall, we see an advantage for 3+ qubits and up.The speed-ups are also good when parallelizing with OpenMP threads (both cases using 16 threads)
After rewriting the PauliRot gates as one-qubit gates of sort, writing AVX kernels for PauliRot may be worth it.
For an entire workflow like time-evolving a QChem Hamiltonian, the gains are slower coming because
PauliRot
is not necessarily the main bottleneck at all scales, but it is once the molecules are big enough. This is shown in the speed-up bar graph below.Possible Drawbacks:
Related GitHub Issues:
[sc-69801]
[sc-71642]