catalyst
catalyst copied to clipboard
Fix lossy type promotion in JAX primitive lowering
https://github.com/PennyLaneAI/pennylane/pull/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 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]