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

Catalyst supports dynamic_one_shot #5766

Merged
merged 40 commits into from
Jun 7, 2024
Merged

Catalyst supports dynamic_one_shot #5766

merged 40 commits into from
Jun 7, 2024

Conversation

vincentmr
Copy link
Contributor

@vincentmr vincentmr commented May 29, 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
    test 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 doc/releases/changelog-dev.md file, summarizing the
    change, and including a link back to the PR.

  • The PennyLane source code conforms to
    PEP8 standards.
    We check all of our code against Pylint.
    To lint modified files, simply pip install pylint, and then
    run pylint pennylane/path/to/file.py.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
Catalyst does not currently support hardware-like execution for dynamic circuits.

Description of the Change:
Modify parse_native_mid_circuit_measurements to handle measurements with a broadcast dimension.
Add special handling of terminal measurements of MCMs.

Benefits:

Possible Drawbacks:

Related GitHub Issues:
[sc-60756]

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.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.

@vincentmr vincentmr changed the title Mcm for loop catalyst3 Catalyst supports dynamic_one_shot May 29, 2024
@vincentmr vincentmr marked this pull request as ready for review May 30, 2024 21:07
Copy link

codecov bot commented May 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.66%. Comparing base (511efa1) to head (8e1b4fc).
Report is 247 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5766      +/-   ##
==========================================
- Coverage   99.66%   99.66%   -0.01%     
==========================================
  Files         415      415              
  Lines       39703    39489     -214     
==========================================
- Hits        39571    39356     -215     
- Misses        132      133       +1     

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

Copy link
Contributor

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

Looks good, although unfortunately between all the squeezing, stacking, list packing and unpacking, and without already knowing the expected data format in different places I found it quite hard to review those kinds of changes and will mostly have to trust you about them 😅

pennylane/measurements/probs.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Copy link
Contributor Author

@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.

Looks good, although unfortunately between all the squeezing, stacking, list packing and unpacking, and without already knowing the expected data format in different places I found it quite hard to review those kinds of changes and will mostly have to trust you about them 😅

Right, sorry about that. I think once all MCM-related PRs go in, this will be a good candidate for refactoring.

pennylane/measurements/probs.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
@vincentmr vincentmr requested a review from mudit2812 May 31, 2024 18:35
@vincentmr vincentmr requested a review from dime10 May 31, 2024 18:38
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Looks great so far! The failing CI seems problematic, and I left a few comments about the changes to the transform as well.

pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
vincentmr and others added 4 commits June 3, 2024 16:30
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
@vincentmr vincentmr requested a review from mudit2812 June 4, 2024 12:16
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Looks great, just one stylistic optional suggestion. Other than that, happy to approve once code coverage is passing.

pennylane/transforms/dynamic_one_shot.py Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
@vincentmr
Copy link
Contributor Author

Other than that, happy to approve once code coverage is passing.

Code coverage will not pass until the CI can pull a Catalyst version supporting the one-shot mode. So should we force merge and come back to it once the Catalyst support is out?

@vincentmr vincentmr requested a review from mudit2812 June 5, 2024 14:48
@mudit2812
Copy link
Contributor

Other than that, happy to approve once code coverage is passing.

Code coverage will not pass until the CI can pull a Catalyst version supporting the one-shot mode. So should we force merge and come back to it once the Catalyst support is out?

I'd prefer to avoid force merging.

You can add # pragma: no cover to the uncovered branches along with a TODO to remove them after the catalyst PR is merged. Probably worth creating a story for the follow up as well and adding it to the P0 epic.

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Left a comment about using # pragma: no cover to silence the coverage errors. An alternative would be to mock qml.compiler.active to always return True and use the mocked function in unit tests.

All other changes look good to me and I'm happy to approve once this coversation is resolved.

@vincentmr
Copy link
Contributor Author

Thanks @mudit2812 . I'll go with # pragma: no cover for now since the tests are already written and ready to cover once the Catalyst support comes in.

@vincentmr vincentmr requested a review from mudit2812 June 5, 2024 17:38
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

Looks great, just a couple of minor things:

pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Show resolved Hide resolved
pennylane/transforms/dynamic_one_shot.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

Happy to approve 💯

@vincentmr vincentmr enabled auto-merge (squash) June 7, 2024 17:02
@vincentmr vincentmr merged commit 7f97ea7 into master Jun 7, 2024
40 checks passed
@vincentmr vincentmr deleted the mcm_for_loop_catalyst3 branch June 7, 2024 17:48
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.

3 participants