Skip to content

The builtin passes and apply_pass use qml.transform(pass_name="name")#2487

Closed
lillian542 wants to merge 12 commits intomainfrom
apply_pass_raises_error
Closed

The builtin passes and apply_pass use qml.transform(pass_name="name")#2487
lillian542 wants to merge 12 commits intomainfrom
apply_pass_raises_error

Conversation

@lillian542
Copy link
Copy Markdown
Contributor

@lillian542 lillian542 commented Feb 18, 2026

Context:
If you use apply_pass with program capture enabled, everything runs but it does not apply the pass. The same problem is true for any builtin pass that is accessed via from catalyst.passes import pass_name. This has created some situations that are difficult to debug.

Description of the Change:
We switch the apply_pass function to use the more general qml.transform(pass_name="name-of-pass") UI instead of PassPipelineWrapper, which isn't compatible with program capture. We also update the builtin passes to use the new more general UI.

Note that there are still two functions in the pass_api, pipeline and apply_pass_plugin, that do return a PassPipelineWrapper, so it is still currently possible to encounter one in specific cases.

Benefits:
Less confusing behaviour when switching to program capture.

Downsides

  • The PassPipelineWrapper raised a clear error message if passed a non-Qnode function, and these errors are no longer raised when we switch to qml.transform.
  • The pipeline and apply_pass_plugin will still return PassPipelineWrapper, which creates an issue if these are used alongside (specifically if they are used before) builtin passes or qml.transform(pass_name...)

[sc-112140][sc-104261]

@paul0403
Copy link
Copy Markdown
Member

@dime10 Now that we have @qml.transform(pass_name="..."), which works with both with and without capture, @albi3ro suggested that we can deprecate catalyst legacy frontend's own @apply_pass, which currently silently does nothing when capture is enabled (instead of explicitly telling the user the pass will not be applied).

Any objections?

@dime10
Copy link
Copy Markdown
Contributor

dime10 commented Feb 18, 2026

@dime10 Now that we have @qml.transform(pass_name="..."), which works with both with and without capture, @albi3ro suggested that we can deprecate catalyst legacy frontend's own @apply_pass, which currently silently does nothing when capture is enabled (instead of explicitly telling the user the pass will not be applied).

Any objections?

Sure, just check with @isaacdevlugt

@albi3ro
Copy link
Copy Markdown
Contributor

albi3ro commented Feb 18, 2026

We can also just update the implementation to use transform(pass_name=pass_name) for the time being.

Comment thread frontend/catalyst/passes/pass_api.py Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md on your branch 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.

@isaacdevlugt
Copy link
Copy Markdown
Contributor

@dime10 Now that we have @qml.transform(pass_name="..."), which works with both with and without capture, @albi3ro suggested that we can deprecate catalyst legacy frontend's own @apply_pass, which currently silently does nothing when capture is enabled (instead of explicitly telling the user the pass will not be applied).
Any objections?

Sure, just check with @isaacdevlugt

@dime10 @albi3ro no issues from my side :). We have something better now!

lillian542 and others added 2 commits February 18, 2026 22:34
@lillian542 lillian542 changed the title Raise an error in apply_pass if program capture is enabled Make apply_pass an alias for qml.transform(pass_name="name") Feb 19, 2026
@lillian542 lillian542 changed the title Make apply_pass an alias for qml.transform(pass_name="name") Make apply_pass an alias for qml.transform(pass_name="name") Feb 19, 2026
Comment thread frontend/catalyst/passes/pass_api.py Outdated
@paul0403
Copy link
Copy Markdown
Member

@lillian542 feel free to delete all the jaxpr lit tests (and I guess the jaxpr printer itself)! Now that we don't go through catalyst legacy frontend's own mechanism, there's no need to check these anymore. The important part of the lit tests is the generated MLIR, as long as those are correct, we're fine.

@paul0403
Copy link
Copy Markdown
Member

Note that "frontend tests" CI fails but "frontend tests: kokkos" CI succeeds because frontend lit tests are only run in the "frontend tests" job, if you were wondering.

@lillian542 lillian542 changed the title Make apply_pass an alias for qml.transform(pass_name="name") The builtin passes and apply_pass useqml.transform(pass_name="name") Feb 23, 2026
@lillian542 lillian542 changed the title The builtin passes and apply_pass useqml.transform(pass_name="name") The builtin passes and apply_pass use qml.transform(pass_name="name") Feb 23, 2026
@andrijapau
Copy link
Copy Markdown
Contributor

Closing in favour of #2525 which contains these changes and some other improvements.

@andrijapau andrijapau closed this Mar 9, 2026
andrijapau added a commit that referenced this pull request Mar 12, 2026
…Lane's new unified transforms API (#2525)

Copies some of the changes made here:
#2487.

The goal of this PR is to get rid of `PassPipelineWrapper` and
`QNodeWrapper` and use the new unified transforms API.

Complimentary PR in PennyLane that follows up on the removal:
PennyLaneAI/pennylane#9123

[sc-112140][sc-104261]

---------

Co-authored-by: lillian542 <Lillian.frederiksen@xanadu.ai>
Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Co-authored-by: Yushao Chen (Jerry) <chenys13@outlook.com>
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.

6 participants