-
Notifications
You must be signed in to change notification settings - Fork 586
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 construct_batch
and transform_program
functions to workflow module
#5084
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @albi3ro! This looks great. I think it's still WIP so I'll come back to look at this later.
erge branch 'construct-batch' of https://github.com/PennyLaneAI/pennylane into construct-batch
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5084 +/- ##
==========================================
- Coverage 99.69% 99.68% -0.01%
==========================================
Files 393 394 +1
Lines 35912 35710 -202
==========================================
- Hits 35801 35598 -203
- Misses 111 112 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me - transform_program
and construct_batch
both look super useful 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really excited to have this in 🍾 most of my comments are about style or docs, lmk what you think
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
…ylane into construct-batch
I'd like some finality on what to do with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Approved, subject to my comments.
To check I understand, this will be used for the drawing and specs functionality?
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Yes this will be for drawing and specs. |
See #5058 for a prototype of the end state.
This PR adds two functions
qml.workflow.construct_batch
andqml.workflow.transform_program
.transform_program(qnode, level)
takes a qnode and a "level" and returns a transform program. The level keyword argument will be used throughconstruct_batch
,draw
,draw_mpl
, andspecs
and indicates a selection from the full transform program.construct_batch(qnode, level)(*args, **kwargs)
takes a qnode and a level and returns a callable with the same signature as the qnode. It then applies the transform program corresponding tolevel
.Additional minor changes and helpers:
qml.transforms.core.expand_fn_transform
: In order to placeqml.Device.expand_fn
into the transform program easily, I added a quick function to convert from a tape->tape function to a transform.TransformContainer.__repr__
: This just makes my life easier when working with transforms.Default the
is_informative
keyword argument toFalse
instead ofNone
when creating a transform. This way a transform created withTransformContainer
has the same default value ofis_informative
. This was causing me headaches when comparing transforms in testing.Slicing into a
TransformProgram
with a slice object returns anotherTransformProgram
instead of a list. Exprog[0:4]
Defined
__contains__
forTransformProgram
. This just made my life easier when playing around and testing things out. example:qml.compile in my_program
.Added some documentation on defined dunder methods in
TransformProgram