-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
construct_batch
and transform_program
functions to workflow m…
…odule (#5084) See #5058 for a prototype of the end state. This PR adds two functions `qml.workflow.construct_batch` and `qml.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 through `construct_batch`, `draw`, `draw_mpl`, and `specs` 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 to `level`. Additional minor changes and helpers: * `qml.transforms.core.expand_fn_transform`: In order to place `qml.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 to `False` instead of `None` when creating a transform. This way a transform created with `TransformContainer` has the same default value of `is_informative`. This was causing me headaches when comparing transforms in testing. * Slicing into a `TransformProgram` with a slice object returns another `TransformProgram` instead of a list. Ex `prog[0:4]` * Defined `__contains__` for `TransformProgram`. 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` --------- Co-authored-by: Thomas R. Bromley <[email protected]> Co-authored-by: Matthew Silverman <[email protected]>
- Loading branch information
1 parent
f51e695
commit b5f302c
Showing
18 changed files
with
1,245 additions
and
132 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.