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

[Capture] First PR for enabling dynamic decompositions with PLxPR enabled #6859

Merged
merged 48 commits into from
Feb 10, 2025

Conversation

PietropaoloFrisoni
Copy link
Contributor

@PietropaoloFrisoni PietropaoloFrisoni commented Jan 20, 2025

Context: The main purpose of this story is to implement a prototype for dynamic decompositions in PL with program capture enabled.

At this stage, we only focus on one-level dynamic decompositions (without implementing additional parameters that can be passed to the interpreter). The UI might change in the future.

Therefore, these are the main current limitations of the prototype introduced in this PR:

  • No arguments can be passed to the interpreter
  • No support for nested decompositions

Description of the Change: As above.

Benefits: We can start capturing the decompositions dynamically with program capture enabled instead of simply returning the operators list at the end.

Possible Drawbacks: Still experimental. It shouldn't cause issues with the current program capture scaffolding.

Related GitHub Issues: None

Related Shortcut Stories: [sc-82690]

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.

@PietropaoloFrisoni PietropaoloFrisoni changed the title qml.cond in decompositions can be captured into PLxPR Exploring how to handle dynamic decompositions with PLxPR enabled Jan 21, 2025
@PietropaoloFrisoni PietropaoloFrisoni marked this pull request as ready for review January 24, 2025 21:59
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.59%. Comparing base (a7514b7) to head (4f95b74).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6859   +/-   ##
=======================================
  Coverage   99.59%   99.59%           
=======================================
  Files         480      480           
  Lines       45510    45517    +7     
=======================================
+ Hits        45325    45332    +7     
  Misses        185      185           

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

@PietropaoloFrisoni PietropaoloFrisoni changed the title Exploring how to handle dynamic decompositions with PLxPR enabled [Capture] First PR for enabling dynamic decompositions with PLxPR enabled Jan 27, 2025
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 good. We haven't had any testing for execution so far, so I'm happy to see that. I'd like some discussions about always relying on default.qubit though. Especially after the conversations in stand-up yesterday, it seems like a good idea to standardize a strategy that everyone can use going forward.

Another thing I noticed is missing integration tests. DecomposeInterpreter is integrated with qml.transforms.decompose, so I'd like to see some testing with that as well instead of just DecomposeInterpreter.

pennylane/transforms/decompose.py Show resolved Hide resolved
@PietropaoloFrisoni
Copy link
Contributor Author

PietropaoloFrisoni commented Feb 10, 2025

I'd like some discussions about always relying on default.qubit though. Especially after the conversations in stand-up yesterday, it seems like a good idea to standardize a strategy that everyone can use going forward.

I totally second that!

In this case, I'm using the device only to explicitly test the result, but in principle, I could do without it and just verify the structure of the jaxpr.

Maybe we can create some kind of 'reference' qubit (not necessarily limited to program capture) so that these tests automatically take place with more than one device. For the moment, it seems to me that the only solution is to continue with default.qubit, because doing this would require further work (and it would be ideal to update the rest of the codebase as well). What do you think?

Another thing I noticed is missing integration tests. DecomposeInterpreter is integrated with qml.transforms.decompose, so I'd like to see some testing with that as well instead of just DecomposeInterpreter.

Good point, now that we have integrated dynamic decompositions with the old interpreter, this would be good. I added some tests in a TestExpandPlxprTransformsDynamicDecompositions class in the same file.

P.S. As you can see in this PR (which enables nested decompositions), the tests will work automatically with autograph enabled and disabled once this PR is merged.

@mudit2812 @josephleekl

Copy link

@josephleekl josephleekl 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 to me, thanks @PietropaoloFrisoni !

@PietropaoloFrisoni PietropaoloFrisoni enabled auto-merge (squash) February 10, 2025 20:36
@PietropaoloFrisoni PietropaoloFrisoni merged commit 729da9f into master Feb 10, 2025
46 checks passed
@PietropaoloFrisoni PietropaoloFrisoni deleted the cond_dynamic_decomp branch February 10, 2025 21:00
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.

4 participants