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 MidMeasureMP Kokkos #658

Merged
merged 35 commits into from
Apr 12, 2024
Merged

Add MidMeasureMP Kokkos #658

merged 35 commits into from
Apr 12, 2024

Conversation

tomlqc
Copy link
Contributor

@tomlqc tomlqc commented Mar 21, 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:
Same as #621 for Lightning-Kokkos

Description of the Change:

  • Add method to obtain the probability in the z-basis on a given wire.
  • Add RNG attribute.
  • Add method to init the RNG attribute with a given seed.
  • Add method to sample from a binomial distribution.
  • Add method to collapse the state vector onto a given branch.
  • Add method which implements the MidMeasureMP workflow.
  • Add bindings to the MidMeasureMP method.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

Related Shortcut Story:
[sc-58334]
[sc-60946]

@tomlqc tomlqc requested a review from vincentmr March 22, 2024 12:49
@tomlqc
Copy link
Contributor Author

tomlqc commented Mar 22, 2024

@vincentmr you may have a look on the C++ implementation, especially about the functor for Kokkos. I'll add the bindings later.

vincentmr and others added 4 commits April 4, 2024 20:46
* Add MCM bindings and tests for L-Kokkos.

* Auto update version

* Refactor collapse.

* Try parallelizing tests.

* Only run test_native_mcm once amongst all workflows since it takes quite a bit of time.

* trigger ci

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.12%. Comparing base (2028317) to head (e4f0716).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #658      +/-   ##
==========================================
+ Coverage   90.91%   97.12%   +6.20%     
==========================================
  Files          64      150      +86     
  Lines        9243    19515   +10272     
==========================================
+ Hits         8403    18953   +10550     
+ Misses        840      562     -278     

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

@vincentmr vincentmr marked this pull request as ready for review April 10, 2024 13:52
@vincentmr vincentmr added the ci:build_wheels Activate wheel building. label Apr 10, 2024
@vincentmr vincentmr requested a review from a team April 11, 2024 13:35
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.

Nice work!

vincentmr and others added 3 commits April 12, 2024 09:04
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 fellas! 💯

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.

Nice job!

vincentmr and others added 3 commits April 12, 2024 14:11
…/Test_StateVectorLKokkos.cpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
…VectorKokkos.hpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
@vincentmr
Copy link
Contributor

Nice job!

Thanks for the suggestions @AmintorDusko .

@vincentmr vincentmr merged commit d0e1c51 into master Apr 12, 2024
83 checks passed
@vincentmr vincentmr deleted the feature/mid-measure-kokkos branch April 12, 2024 20:40
multiphaseCFD pushed a commit that referenced this pull request Apr 12, 2024
* collapse() and normalized() with Kokkos

* Auto update version

* CodeFactor

* normalize() abort if norm is zero

* unittest for normalize()

* Auto update version

* unittest for normalize() in LighningQubit

* Auto update version

* Add MCM bindings and tests for L-Kokkos. (#672)

* Add MCM bindings and tests for L-Kokkos.

* Auto update version

* Refactor collapse.

* Try parallelizing tests.

* Only run test_native_mcm once amongst all workflows since it takes quite a bit of time.

* trigger ci

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>

* Do not run test_native_mcm with LK-GPU.

* Auto update version

* trigger ci

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/bindings/LKokkosBindings.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Auto update version

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Increase shotsfor flaky test_composite_mcm_single_measure_obs

* Create separate device_allowed_operations list for ops supported by the device but not Catalyst.

* Use isinstance instead of name comparison.

* Check projector.

* Update operations at device init.

* Modify stopping condition in LK.

* Cannot use instance with Hamiltonian check.

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/tests/Test_StateVectorLKokkos.cpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Remove obsolete comment.

* Auto update version

* trigger ci

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
multiphaseCFD pushed a commit that referenced this pull request Apr 12, 2024
* collapse() and normalized() with Kokkos

* Auto update version

* CodeFactor

* normalize() abort if norm is zero

* unittest for normalize()

* Auto update version

* unittest for normalize() in LighningQubit

* Auto update version

* Add MCM bindings and tests for L-Kokkos. (#672)

* Add MCM bindings and tests for L-Kokkos.

* Auto update version

* Refactor collapse.

* Try parallelizing tests.

* Only run test_native_mcm once amongst all workflows since it takes quite a bit of time.

* trigger ci

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>

* Do not run test_native_mcm with LK-GPU.

* Auto update version

* trigger ci

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/bindings/LKokkosBindings.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Auto update version

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Increase shotsfor flaky test_composite_mcm_single_measure_obs

* Create separate device_allowed_operations list for ops supported by the device but not Catalyst.

* Use isinstance instead of name comparison.

* Check projector.

* Update operations at device init.

* Modify stopping condition in LK.

* Cannot use instance with Hamiltonian check.

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/tests/Test_StateVectorLKokkos.cpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Remove obsolete comment.

* Auto update version

* trigger ci

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
multiphaseCFD added a commit that referenced this pull request Apr 19, 2024
* Init commit

* Auto update version

* Add MidMeasureMP Kokkos (#658)

* collapse() and normalized() with Kokkos

* Auto update version

* CodeFactor

* normalize() abort if norm is zero

* unittest for normalize()

* Auto update version

* unittest for normalize() in LighningQubit

* Auto update version

* Add MCM bindings and tests for L-Kokkos. (#672)

* Add MCM bindings and tests for L-Kokkos.

* Auto update version

* Refactor collapse.

* Try parallelizing tests.

* Only run test_native_mcm once amongst all workflows since it takes quite a bit of time.

* trigger ci

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>

* Do not run test_native_mcm with LK-GPU.

* Auto update version

* trigger ci

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/bindings/LKokkosBindings.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Auto update version

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Increase shotsfor flaky test_composite_mcm_single_measure_obs

* Create separate device_allowed_operations list for ops supported by the device but not Catalyst.

* Use isinstance instead of name comparison.

* Check projector.

* Update operations at device init.

* Modify stopping condition in LK.

* Cannot use instance with Hamiltonian check.

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/tests/Test_StateVectorLKokkos.cpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/StateVectorKokkos.hpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Remove obsolete comment.

* Auto update version

* trigger ci

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Trigger CI

* make format

* Auto update version

* Trigger CIs

* Auto update version

* Trigger CI

* Auto update version

* add more docstring

* add changelog

* Update pennylane_lightning/core/src/simulators/lightning_gpu/utils/cuStateVecError.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_gpu/utils/cuStateVecError.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_gpu/utils/cuStateVec_helpers.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_gpu/utils/cuStateVecError.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_gpu/utils/cuStateVec_helpers.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_gpu/utils/cuStateVec_helpers.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/utils/cuda_utils/cuError.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_gpu/utils/cuStateVecError.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Trigger CI

* make format

* quick fix

* fix

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Thomas Germain <115888357+tomlqc@users.noreply.github.com>
Co-authored-by: Vincent Michaud-Rioux <vincent.michaud-rioux@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants