[NNC] Some ops have type promotion logic which adds extra casts & does compute in different dtype than eager #49178
Labels
module: bootcamp
We plan to do a full writeup on the issue, and then get someone to do it for onboarding
NNC
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
馃悰 Bug
Many NNC type promotion goes through a common path which promotes inputs according to the highest input type, and then after compute, casts the output to whichever output type was recorded when the op was run in eager.
Because we have the output type specified, all NNC ops will give the correct dtype. However, the compute may be done in a different dtype than eager, and there may be extraneous casts added.
In the (worst) case of something like,
We will cast all three tensor inputs to int32, do the addcmul, then cast the operation back. As opposed to eager, which will just cast
value=1
to int16.The advantage of the current approach is that we are guaranteed to have the same output dtype. I think ops could gradually be migrated over to have the correct casting behavior.
Most ops do promote to the highest dtype, so this isn't that big of an issue, but it does come up.
TODO:
To Reproduce
Comment out the output type casting of the various
comput{number}Operands
Run
python test/test_jit_fuser_te..py
The text was updated successfully, but these errors were encountered: