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

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

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 (9744822) to head (e7a2775).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6859   +/-   ##
=======================================
  Coverage   99.59%   99.59%           
=======================================
  Files         480      480           
  Lines       45495    45504    +9     
=======================================
+ Hits        45310    45319    +9     
  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. Left a few comments. I'm confused why all the QNode tests explicitly disable autograph. Might be worth parametrizing the tests to check with both autograph=False and True

pennylane/operation.py Outdated Show resolved Hide resolved
pennylane/transforms/decompose.py Outdated Show resolved Hide resolved
Comment on lines 215 to 223
@staticmethod
def _compute_plxpr_decomposition(phi, wires):

if phi > 0.5:
qml.RX(phi, wires=wires)

else:
qml.RY(phi, wires=wires)

Copy link
Contributor

Choose a reason for hiding this comment

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

For this to work, don't you need to set autograph=True in the call to make_plxpr in _plxpr_decomposition?

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