Hi,
Does the same error happen in normal FP32 training?
If not, I think running the block in autocast(enabled=False) context is one choice. But use this context, it’ll be necessary to convert some input tensors to FP32.

autocast(enabled=False) subregions can be nested in autocast-enabled regions. Locally disabling autocast can be useful, for example, if you want to force a subregion to run in a particular dtype. Disabling autocast gives you explicit control over the execution type. In the subregion, inputs from the surrounding region should be cast to dtype before use: (quote from Automatic Mixed Precision package - torch.cuda.amp — PyTorch 1.8.0 documentation 3)