hughperkins:

what might go wrong if we simply cast everything to the same type (16 vs 32bits) as one of the tensors, but without using an autocast(enabled=False) guard around this?


If the forward pass of your op consists only of the custom kernel itself, that’s fine. Autocast doesn’t know about your kernel (unless you register it like in the dispatch tutorial) and won’t touch the inputs.
If your op consists of your custom kernel + a few torch.* ops, and you don’t locally autocast(enabled=False), the torch.* ops still might be affected by autocast, which you may or may not want.
For torch.autograd.Functions, the @custom_fwd(cast_inputs=torch.float32/16) 16 takes care of casting inputs and disabling autocast for the forward body.