Could you try to store the tensors, which create the NaN output so that we could further debug?
Alternatively, could you post the shapes and stats of the tensors, so that we could run it with random values and try to reproduce the failure?