Closed mehrdad2m closed 1 month ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.98%. Comparing base (
f1c846d
) to head (3807912
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Context: This PR fixes an unexpected crash in initializeCotangents when using float32 in callbacks. The crash happens when creating ConstantFloatOp operation. e.g. testcase
test_scalar_in_array_out_float32_wrong
infrontend/test/pytest/test_callback.py
would result in the following crash message:Assertion failed: (succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))), function get, file StorageUniquerSupport.h, line 181.
Description of the Change: Since APFloat(0.0) is always a float64, changed the constructor to use the precision semantics of the desired float
Benefits: Will print better assertion error when using float32 in callbacks. The improved assertion error is:
Possible Drawbacks: callbacks will still raise an exception. Although this happens only when value returned from pure_callback was not
dtype
d float32. if both observed and expected output of the pure_callback aredtype
d float32, there would be no assertion raised.Related GitHub Issues: https://github.com/PennyLaneAI/catalyst/issues/844
[sc-68042]