-
Notifications
You must be signed in to change notification settings - Fork 585
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
Make Exp.decomposition
jit compatible
#6082
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6082 +/- ##
==========================================
- Coverage 99.66% 99.65% -0.01%
==========================================
Files 430 430
Lines 41836 41548 -288
==========================================
- Hits 41697 41406 -291
- Misses 139 142 +3 ☔ View full report in Codecov by Sentry. |
Exp.decomposition
qjit compatibleExp.decomposition
jit compatible
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.
Few comments and questions. Overall looking good :)
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 @astralcai for providing this fix 💯
PennyLaneAI/pennylane#6082 unearthed that in an attempt to be more lenient with user supplied types, Catalyst eagerly converts any type to the required float64 type for gate parameters, including when this results in a loss of data (like converting complex numbers to floats). This fixes the issue as well as providing some minor code cleanup, and fixing a long-standing issue of potentially undefined variables in the Python code. In order to help users with the proposed fix in [#pennylane/6082 ](PennyLaneAI/pennylane#6082) for the decomposition of `Exp`, the error message for complex gate parameters mentions potential non-unitary operators like the exponential with real exponent. [sc-71066]
Context:
The result of
Exp.decomposition
depends whether the coefficient is purely imaginary or not, which makes it incompatible with qjit.Description of the Change:
ChangeExp.decomposition
to queue decomposed operations in a temporary queueing context, and then convert it to a list of operations, making it compatible withqml.cond
Change
Exp.decomposition
to not raise an error when the coefficient is real.Benefits:
Workflows that involve
Exp
are now compatible withqjit
andjax.jit
Possible Drawbacks:
This is a very hacky solution.Exp.decomposition
is still not compatible withjax.jit
.When applying
qml.exp
on an operator with real coefficients, in a jitted context, no error is thrown.Related GitHub Issues:
Fixes PennyLaneAI/catalyst#923
Also Fixes #5993
[sc-68711]