-
Notifications
You must be signed in to change notification settings - Fork 579
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
Plxpr can capture operations #5511
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.
Some comments :)
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5511 +/- ##
==========================================
- Coverage 99.68% 99.67% -0.01%
==========================================
Files 412 414 +2
Lines 38666 38522 -144
==========================================
- Hits 38545 38398 -147
- Misses 121 124 +3 ☔ View full report in Codecov by Sentry. |
…neAI/pennylane into plxpr-capture-operations
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
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.
This is in really good shape now :) Thanks for the continued effort!
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
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 😍 The simplicity of it is really nice especially. I just have a few questions that came up while reading through 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.
🙌
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
**Context:** In PR #5511 , we introduced the meta type `qml.capture.MetaOperator` that hijacked the class creation processes. The `__call__` signature for these classes got altered to the completely general `(cls, *args, **kwargs)` instead of the more specific version used by `__init__`. **Description of the Change:** Adds a `__signature__` property to `MetaOperator` that ensures that the signature will always be the `__init__` signature. **Benefits:** Signatures continue to match the `__init__` definition. **Possible Drawbacks:** The metaprogramming black magic may still have other consequences we still aren't aware of. This fixes the particular signature issue, but it still shows the consequences of metaprogramming. **Related GitHub Issues:** Fixes #5724 [sc-63734] <img width="487" alt="Screenshot 2024-05-22 at 9 42 10 AM" src="https://github.com/PennyLaneAI/pennylane/assets/6364575/1abf41ce-b72a-4734-a069-3dd37e7f8c28">
HIGHLY EXPERIMENTAL FEATURE
Context:
To improve integration with catalyst, we want a way to be able to natively capture the creation of quantum operations into an intermediate representation. This is one of the early PR's for this experimental push.
Description of the Change:
This PR adds a
PLXPR
metaclass thatOperator
uses. This allows for the capture of allOperator
classes into jaxpr.We can also return the jaxpr to normal pennylane qfunc behaviour via
jax.core.eval_jaxpr
:Benefits:
Possible Drawbacks:
Metaprogramming in python is an edge skill, and often not the best way to solve a problem. Messing around with things like this can often have unintended consequences down the line.
With PLXPR, wires will be restricted to be jax-tracable friendly labels.
Related GitHub Issues:
[sc-61199]