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

Add transform dispatcher to programs #4559

Merged
merged 17 commits into from
Aug 31, 2023
Merged

Conversation

rmoyard
Copy link
Contributor

@rmoyard rmoyard commented Aug 30, 2023

Description of the Change:

It makes very easy for users to create a custom TranformProgram.

program = TransformProgram()
program.add_tranform(transform)

This will be used in the device to create the pre processing program.

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

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! Thanks Romain

pennylane/transforms/core/transform_dispatcher.py Outdated Show resolved Hide resolved
pennylane/transforms/core/transform_dispatcher.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (975d3f4) 99.66% compared to head (232ea70) 99.66%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4559   +/-   ##
=======================================
  Coverage   99.66%   99.66%           
=======================================
  Files         376      376           
  Lines       33047    33059   +12     
=======================================
+ Hits        32937    32949   +12     
  Misses        110      110           
Files Changed Coverage Δ
pennylane/transforms/core/transform_program.py 98.95% <100.00%> (+0.14%) ⬆️

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

rmoyard and others added 2 commits August 31, 2023 09:15
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

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

the order still seems strange to me, but it's clear enough. Curious about in-place changes as mentioned in comments.

I'm also wondering - you chose dispatcher.add_to_program(program) instead of program.add_dispatcher(dispatcher). The latter seems more intuitive (kinda like list.append(item) instead of item.add_to_list(list)), could you explain why? I almost feel like we can update push_back to just check if it's passed a dispatcher or a container, then do the right thing depending on that. Or just put it into a new function like push_transform or push_dispatcher (the former will make more sense to end-users)

pennylane/transforms/core/transform_dispatcher.py Outdated Show resolved Hide resolved
@rmoyard rmoyard changed the title Add to program in the transform dispatcher Add transform dispatcher to programs Aug 31, 2023
@rmoyard rmoyard requested a review from timmysilv August 31, 2023 17:32
Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

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

this looks really great! to be clear, expand_transforms don't all need to be at the front of a program, just before their associated (regular) transform, right?

pennylane/transforms/core/transform_program.py Outdated Show resolved Hide resolved
pennylane/transforms/core/transform_program.py Outdated Show resolved Hide resolved
rmoyard and others added 4 commits August 31, 2023 14:25
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
@rmoyard
Copy link
Contributor Author

rmoyard commented Aug 31, 2023

@timmysilv the only constrain for expand transforms is that they need to be just before applying the transform itself.

@rmoyard rmoyard requested a review from timmysilv August 31, 2023 18:28
Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

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

🎉

@rmoyard rmoyard enabled auto-merge (squash) August 31, 2023 18:39
@rmoyard rmoyard merged commit 6828345 into master Aug 31, 2023
39 checks passed
@rmoyard rmoyard deleted the add_to_program_in_dispatcher branch August 31, 2023 19:17
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.

None yet

4 participants