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

Transforms can be captured with PLxPR #6633

Merged
merged 20 commits into from
Dec 2, 2024
Merged

Transforms can be captured with PLxPR #6633

merged 20 commits into from
Dec 2, 2024

Conversation

mudit2812
Copy link
Contributor

@mudit2812 mudit2812 commented Nov 25, 2024

[sc-72804] [sc-72803]

This PR adds a primitive for capturing transforms.

Description of change

  • Add a primitive to capture transforms: every time a transform is created, it automatically gets registered as a primitive
  • This primitive is currently only for capturing transforms and does not actually transform the input function.
  • This primitive gets bound (binded?) when calling the transform on the QNode or a function.
    • When applied to a function, the transform is captured as a higher-order primitive. Evaluating the subsequent JAXPR doesn't do anything (i.e, the inner JAXPR is evaluated without any transformations)
    • When applied to a QNode, the transform is appended to the QNode's TransformProgram as well so that executing QNodes applies the transform(s) to the constructed tape, and also captured as a primitive.
  • Add plxpr_transform attribute to TransformDispatcher and TransformContainer. This is not currently used and is being added here to set up scaffolding in pennylane.transfoms.core for Add TransformTrace, TransformTracer and TransformInterpreter classes for transforming PLxPR #6389 .

Benefits
Transforms can be captured into PLxPR and no extra work is required when creating new transforms

@mudit2812 mudit2812 changed the title Transforms can be captured with PlxPR Transforms can be captured with PLxPR Nov 26, 2024
@mudit2812 mudit2812 marked this pull request as ready for review November 26, 2024 22:07
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.65%. Comparing base (343ecc1) to head (ce560d5).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6633   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files         459      459           
  Lines       43217    43262   +45     
=======================================
+ Hits        43068    43113   +45     
  Misses        149      149           

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

@mudit2812 mudit2812 requested a review from albi3ro November 27, 2024 19:27
Copy link
Contributor

@PietropaoloFrisoni PietropaoloFrisoni left a comment

Choose a reason for hiding this comment

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

Thanks, no blockers from me.

It seems to me that we are not systematically using type hints anymore, so I guess this should not be a requirement for new changes in the codebase

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
@mudit2812 mudit2812 requested a review from albi3ro November 28, 2024 21:23
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

👍

@mudit2812 mudit2812 enabled auto-merge (squash) December 2, 2024 15:10
@mudit2812 mudit2812 merged commit d3f9a7a into master Dec 2, 2024
46 checks passed
@mudit2812 mudit2812 deleted the transform-prim branch December 2, 2024 15:55
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