-
Notifications
You must be signed in to change notification settings - Fork 35
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
Create a frontend UI for users to specify quantum compilation pipelines #1131
Conversation
…_sequence infrastructure, under the catalyst.passes module
@rmoyard The epic description says the zne mitigation pass should go into the The spirit of the epic is that the
Thoughts on this? Update: we decided to exclude ZNE |
Marking ready for review to check CI. Two remaining items:
|
I have some thoughts/questions about the design of the pipeline. Something that is worth clearing up is the definition of a "pass". My understanding of a compiler optimization pass is a transformation from one representation of the code to another without changing its functionality with hope that the transformed version is more optimized (runs faster, better memory usage, ...). If the answer to the question is yes then ignore this comment :) |
…fail by merging the `pass_pipeline` argument of QFunc.__call__ into its **kwargs
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.
Very nice work 🚀
Summary of results from discussion:
This eliminates the need for matching target functions by name. |
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, here are some comments
@@ -77,6 +77,10 @@ class CompileOptions: | |||
experimental_capture (bool): If set to ``True``, | |||
use PennyLane's experimental program capture capabilities | |||
to capture the function for compilation. | |||
circuit_transform_pipeline (Optional[dict[str, dict[str, str]]]): |
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.
No action here, but @josh146 @isaacdevlugt this will soon beat the number of qnode's arguments.
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.
Great job @paul0403 ! Some UI to figure out but happy to approve as a first step 👍
…es (#1131) **Context:** We wish to create a frontend `pipeline` function for users to specify what circuit transformation passes to run in the dictionary form: https://app.shortcut.com/xanaduai/epic/67492/p1-a-ui-is-available-for-users-to-specify-quantum-compilation-pipelines-from-python **Description of the Change:** A new API decorator function `catalyst.passes.pipeline` can be applied to qnodes. The decorator takes in a dictionary specifying what circuit transformation passes to run on the qnode with what options, and adds the passes to the `transform_named_sequence`. In addition, `qjit` now takes in a kwarg `circuit_transform_pipeline` which expects the same pipeline dictionary. This will apply the pipeline to all qnodes in the qjit. To test the pipeline, we added the boilerplate for a merge_rotation pass with a pass option. The pass is currently empty and does nothing. The merge_rotation boilerplate pass is not exposed as a user-facing API, and only exists for the purpose of testing the pipeline. **Benefits:** User can specify pass pipelines. **Possible Drawbacks:** There are two items of improvements possible: 1. The target qnode of the pass is recorded by name. This is not optimal. The quantum scope work will likely put each qnode into a module instead of a `func.func ... attributes {qnode}` in mlir. When that is in place, the qnode's module can have a proper attribute (as opposed to discardable) that records its transform schedule, i.e. ``` module_with_transform @name_of_module { // transform schedule } { // contents of the module } ``` This eliminates the need for matching target functions by name. 2. The number of `qjit` kwargs is maybe too many. As of now we implement the syntax specified by the epic, but there could be an alternate design. [sc-67520]
Context:
We wish to create a frontend
pipeline
function for users to specify what circuit transformation passes to run in the dictionary form.https://app.shortcut.com/xanaduai/epic/67492/p1-a-ui-is-available-for-users-to-specify-quantum-compilation-pipelines-from-python
Description of the Change:
A new API decorator function
catalyst.passes.pipeline
can be applied to qnodes. The decorator takes in a dictionary specifying what circuit transformation passes to run on the qnode with what options, and adds the passes to thetransform_named_sequence
.In addition,
qjit
now takes in a kwargcircuit_transform_pipeline
which expects the same pipeline dictionary. This will apply the pipeline to all qnodes in the qjit.To test the pipeline, we added the boilerplate for a merge_rotation pass with a pass option. The pass is currently empty and does nothing. The merge_rotation boilerplate pass is not exposed as a user-facing API, and only exists for the purpose of testing the pipeline.
Benefits:
User can specify pass pipelines.
Possible Drawbacks:
There are two items of improvements possible:
func.func ... attributes {qnode}
. When that is in place, the qnode's module can have a proper attribute (as opposed to discardable) that records its transform schedule, i.e.This eliminates the need for matching target functions by name.
qjit
kwargs is maybe too many. As of now we implement the syntax specified by the epic, but there could be an alternate design.[sc-67520]