In your forward function, you can add extra prints to check the values of the current batch (potentially with if checks to only print for problematic batches).
You can check the max difference between the different samples in your batch for example.
You can also save the batch on disk at every iteration. That way, when it crashes, you can load the last saved batch to inspect the values for it.