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 MCM bindings and tests for L-Kokkos. #672

Merged
merged 6 commits into from
Apr 10, 2024

Conversation

vincentmr
Copy link
Contributor

@vincentmr vincentmr commented Apr 5, 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:

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:
[sc-60946]

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (30e51b9) to head (008ac80).
Report is 1 commits behind head on feature/mid-measure-kokkos.

Additional details and impacted files
@@                      Coverage Diff                       @@
##           feature/mid-measure-kokkos     #672      +/-   ##
==============================================================
+ Coverage                       98.65%   98.70%   +0.04%     
==============================================================
  Files                             172      172              
  Lines                           24458    24475      +17     
==============================================================
+ Hits                            24128    24157      +29     
+ Misses                            330      318      -12     

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

@vincentmr vincentmr added the ci:build_wheels Activate wheel building. label Apr 8, 2024
Copy link
Contributor

@tomlqc tomlqc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to run this:

import numpy as np
import pennylane as qml

dev = qml.device("lightning.kokkos", wires=3)

@qml.qnode(dev)
def circuit(x, y):
    qml.RY(x, wires=0)
    qml.CNOT(wires=[0, 1])
    m_0 = qml.measure(1)

    qml.cond(m_0, qml.RY)(y, wires=0)
    return qml.probs(wires=[0])

circuit(np.pi/2, np.pi/4)

I got

Traceback (most recent call last):
  File "/home/thomas.germain/PennyLane/pennylane-lightning/debug.py", line 20, in <module>
    circuit(np.pi/2, np.pi/4)
  File "/home/thomas.germain/PennyLane/pennylane/pennylane/workflow/qnode.py", line 1085, in __call__
    res = self._execution_component(args, kwargs, override_shots=override_shots)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thomas.germain/PennyLane/pennylane/pennylane/workflow/qnode.py", line 1039, in _execution_component
    res = qml.execute(
          ^^^^^^^^^^^^
  File "/home/thomas.germain/PennyLane/pennylane/pennylane/workflow/execution.py", line 603, in execute
    tapes, program_post_processing = transform_program(tapes)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thomas.germain/PennyLane/pennylane/pennylane/transforms/core/transform_program.py", line 509, in __call__
    new_tapes, fn = transform(tape, *targs, **tkwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thomas.germain/PennyLane/pennylane/pennylane/transforms/dynamic_one_shot.py", line 94, in dynamic_one_shot
    output_tapes = [aux_tape] * tape.shots.total_shots
                   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
TypeError: can't multiply sequence by non-int of type 'NoneType'

Have I done something wrong in my setup? (The C++ tests run successfully.)

@tomlqc
Copy link
Contributor

tomlqc commented Apr 8, 2024

A more general question: Why are lightning_qubit.py and lightning_kokkos.py so different? Is it because only LQ is on the new dev API or did we have such big differences before too?

@vincentmr
Copy link
Contributor Author

Have I done something wrong in my setup? (The C++ tests run successfully.)

Looks like PennyLane might not be the right version.

@vincentmr
Copy link
Contributor Author

A more general question: Why are lightning_qubit.py and lightning_kokkos.py so different? Is it because only LQ is on the new dev API or did we have such big differences before too?

That's right, it is an old/new API difference.

@vincentmr vincentmr marked this pull request as ready for review April 9, 2024 15:34
@vincentmr vincentmr merged commit 3f3ab86 into feature/mid-measure-kokkos Apr 10, 2024
85 checks passed
@vincentmr vincentmr deleted the feature/lk_mcms branch April 10, 2024 12:55
vincentmr added 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 <[email protected]>

* Auto update version

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

* 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 <[email protected]>

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

Co-authored-by: Amintor Dusko <[email protected]>

* 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 <[email protected]>
Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Co-authored-by: Amintor Dusko <[email protected]>
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 <[email protected]>

* Auto update version

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

* 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 <[email protected]>

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

Co-authored-by: Amintor Dusko <[email protected]>

* 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 <[email protected]>
Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Co-authored-by: Amintor Dusko <[email protected]>
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 <[email protected]>

* Auto update version

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

* 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 <[email protected]>

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

Co-authored-by: Amintor Dusko <[email protected]>

* 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 <[email protected]>
Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Co-authored-by: Amintor Dusko <[email protected]>
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 <[email protected]>

* Auto update version

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

* 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 <[email protected]>

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

Co-authored-by: Amintor Dusko <[email protected]>

* 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 <[email protected]>
Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Co-authored-by: Amintor Dusko <[email protected]>

* 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 <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

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

Co-authored-by: Ali Asadi <[email protected]>

* 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 <[email protected]>
Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Vincent Michaud-Rioux <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Co-authored-by: Amintor Dusko <[email protected]>
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.

2 participants