-
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
(LK-C-Base) Add native controlled operation support for Lightning Kokkos #950
Conversation
d5ae740
to
fd9df9f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #950 +/- ##
==========================================
- Coverage 97.29% 95.85% -1.44%
==========================================
Files 229 229
Lines 36908 38841 +1933
==========================================
+ Hits 35909 37232 +1323
- Misses 999 1609 +610 ☔ View full report in Codecov by Sentry. |
… Lightning Kokkos (#952) ### 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`. - [ ] 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:** **Description of the Change:** This PR adds support for named controlled 1-qubit gates (e.g. PauliX / RX / PhaseShift / Hadamard / Rot / GlobalPhase). These are defined in `BasicGateFunctors.hpp`, and are applied through `applyNC1Functor` defined in the same file. **Benefits:** Performance benchmarks for gates are shown here: https://www.notion.so/xanaduai/Lightning-Kokkos-Native-Controlled-Operation-Gate-Benchmarks-12ebc6bd17648017a2dcd237748b24fe **Possible Drawbacks:** **Related GitHub Issues:** [sc-76773]
… to Lightning Kokkos (#953) ### 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`. - [ ] 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:** **Description of the Change:** This PR adds support for named controlled 2/4-qubit gates (e.g. Swap / IsingXX / SingleExcitation / Double Excitation). These are defined in `BasicGateFunctor.hpp`, and are applied through `applyNC2Functor` and `applyNC4Functor` defined in the same file. **Benefits:** Performance benchmarks for gates are shown here: https://www.notion.so/xanaduai/Lightning-Kokkos-Native-Controlled-Operation-Gate-Benchmarks-12ebc6bd17648017a2dcd237748b24fe **Possible Drawbacks:** **Related GitHub Issues:** [sc-76774]
### 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`. - [ ] 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:** **Description of the Change:** This PR adds support for controlled multiRZ for Lightning Kokkos. This is defined in `BasicGateFunctor.hpp`, and is applied through `applyNCNFunctor` defined in the same file. **Benefits:** Performance benchmarks for gates are shown here: https://www.notion.so/xanaduai/Lightning-Kokkos-Native-Controlled-Operation-Gate-Benchmarks-12ebc6bd17648017a2dcd237748b24fe **Possible Drawbacks:** **Related GitHub Issues:** [sc-76775]
### 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`. - [ ] 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:** **Description of the Change:** This PR adds support for controlled QubitUnitary for Lightning Kokkos. There are specialized implementations for 1/2/3-qubits (`applyNC1/2/3QubitOpFunctor`) and a general case implementation (`NCMultiQubitOpFunctor`). These functors are defined in `MatrixGateFunctors.hpp`. These are called by `applyControlledMatrix` or `applyOperation`/`applyNCMultiQubitOp` in `StateVectorKokkos.hpp` **Benefits:** Performance benchmarks for gates are shown here: https://www.notion.so/xanaduai/Lightning-Kokkos-Native-Controlled-Operation-Gate-Benchmarks-12ebc6bd17648017a2dcd237748b24fe **Possible Drawbacks:** **Related GitHub Issues:** [sc-76776]
Thanks @josephleekl . Nice one! It only needs 1 param passed to the device for the |
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 @josh146 ! LGTM. Will approve after this final round.
pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.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.
Great work @josephleekl! Happy to approve 🥳
pennylane_lightning/core/src/simulators/lightning_kokkos/utils/UtilKokkos.hpp
Outdated
Show resolved
Hide resolved
pennylane_lightning/core/src/simulators/lightning_kokkos/utils/UtilKokkos.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! Happy to approve.
…/UtilKokkos.hpp Co-authored-by: Ali Asadi <[email protected]>
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:
Native arbitrary controlled operations have already been implemented in Lightning Qubit and Lightning GPU. This PR adds support for controlled operations to Lightning Kokkos as well. This PR is the base branch of combination of multiple PRs (1, 2, 3, 4, 5, 6, 7)
Description of the Change:
Controlled named-gates, matrix, generators, and adjoint differentiation capability is added to Lightning Kokkos C++ layer.
Benefits:
Better performance for controlled operations in Lightning Kokkos (CPU + GPU). Adjoint differentiation now supported in Lightning Kokkos.
Possible Drawbacks:
Related GitHub Issues:
[sc-78995]