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

Update kokkos files from catalyst repo to support MCM seeding #819

Merged
merged 7 commits into from
Jul 26, 2024

Conversation

paul0403
Copy link
Contributor

@paul0403 paul0403 commented Jul 26, 2024

Context:
The lightning kokkos files in the Catalyst repo has changed since #770. We make a small update to track these changes.

The Catalyst PR that made the changes added seeding to qjit: PennyLaneAI/catalyst#936

Description of the Change:

Benefits: unblocks kokkos with catalyst

Possible Drawbacks:

Related GitHub Issues:

… We make a small update to track these changes.

The Catalyst PR adds seeding to qjit: PennyLaneAI/catalyst#936
@paul0403 paul0403 requested review from dime10 and a team July 26, 2024 13:49
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.57%. Comparing base (d1b4007) to head (5688885).
Report is 88 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (d1b4007) and HEAD (5688885). Click for more details.

HEAD has 34 uploads less than BASE
Flag BASE (d1b4007) HEAD (5688885)
40 6
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #819       +/-   ##
===========================================
- Coverage   98.58%   87.57%   -11.01%     
===========================================
  Files         114       73       -41     
  Lines       18064    11368     -6696     
===========================================
- Hits        17808     9956     -7852     
- Misses        256     1412     +1156     

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

Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

So this seed is only used for the measure RNG. Is that intended? Otherwise looks good to me, but please update the change log.

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.

Hmm... SetDevicePRNG is a virtual function with default impl. The first method of this kind in the QuantumDevice API.

/home/runner/work/pennylane-lightning/pennylane-lightning/Build/pennylane_lightning/core/src/simulators/lightning_kokkos/catalyst/include/QuantumDevice.hpp:125:46: error: unused parameter ‘gen’ [-Werror=unused-parameter]
  125 |     virtual void SetDevicePRNG(std::mt19937 *gen){};

You need to use [[maybe_unused]] for gen to get all actions PASS.

@paul0403
Copy link
Contributor Author

So this seed is only used for the measure RNG. Is that intended? Otherwise looks good to me, but please update the change log.

This is intended (sampling could not be seeded from the catalyst repo as it is done through Pennylane::LightningKokkos/Qubit::Measures::Measurements)

https://github.com/PennyLaneAI/catalyst/blob/a49e0bc9f828a28aa8cae7d07c64d09d84713ef4/runtime/lib/backend/lightning/lightning_dynamic/LightningSimulator.cpp#L304

@paul0403
Copy link
Contributor Author

Hmm... SetDevicePRNG is a virtual function with default impl. The first method of this kind in the QuantumDevice API.

/home/runner/work/pennylane-lightning/pennylane-lightning/Build/pennylane_lightning/core/src/simulators/lightning_kokkos/catalyst/include/QuantumDevice.hpp:125:46: error: unused parameter ‘gen’ [-Werror=unused-parameter]
  125 |     virtual void SetDevicePRNG(std::mt19937 *gen){};

You need to use [[maybe_unused]] for gen to get all actions PASS.

This should be updated in the catalyst repo I assume? Not that familiar with how the two repos see each other but seems like QuantumDevice.hpp is tracked from catalyst repo

@paul0403
Copy link
Contributor Author

Hmm... SetDevicePRNG is a virtual function with default impl. The first method of this kind in the QuantumDevice API.

This is because not all devices can be seeded, so in the device base class we need to supply a default implementation of doing nothing, and let the seedable devices override them.

paul0403 added a commit to PennyLaneAI/catalyst that referenced this pull request Jul 26, 2024
…evice.hpp/SetDevicePRNG(std::mt19937 *gen)` as `[[maybe_unused]]`, as some devices (e.g. openqasm and oqc) do not support seeding has this argument has no effect in the default implementation of this setter.

At a more superficial level, this is to make the tests in PennyLaneAI/pennylane-lightning#819 pass.
.github/CHANGELOG.md Outdated Show resolved Hide resolved
.github/CHANGELOG.md Outdated Show resolved Hide resolved
paul0403 added a commit to PennyLaneAI/catalyst that referenced this pull request Jul 26, 2024
…antumDevice.hpp/SetDevicePRNG()` (#963)

**Context:**
Marking the `std::mt19937 *gen` argument in
`runtime/include/QuantumDevice.hpp/SetDevicePRNG(std::mt19937 *gen)` as
`[[maybe_unused]]`, as some devices (e.g. openqasm and oqc) do not
support seeding and this argument has no effect in the default
implementation of this setter.

At a more superficial level, this is to make the tests in
PennyLaneAI/pennylane-lightning#819 pass.
Copy link
Member

@multiphaseCFD multiphaseCFD left a comment

Choose a reason for hiding this comment

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

Thanks @paul0403 ! LGTM.

Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @paul0403 .

@paul0403 paul0403 changed the title Update kokkos files from catalyst repo Update kokkos files from catalyst repo to support MCM seeding Jul 26, 2024
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.

🙌

@paul0403 paul0403 merged commit 10dc3a9 into master Jul 26, 2024
83 of 84 checks passed
@paul0403 paul0403 deleted the update_catalyst_kokkos_seed branch July 26, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants