functorch icon indicating copy to clipboard operation
functorch copied to clipboard

Check Grad state before backprop AND preserve RNG state

Open anijain2305 opened this issue 3 years ago • 2 comments

@Chillee

One thing I am little skeptical about this is that - I could not come up with a handwritten testcase where the output requires_grad is True and grad_state is False.

But, this scenario comes up in TorchDynamo. Not sure if something is wrong with TorchDynamo here.

anijain2305 avatar Apr 20 '22 01:04 anijain2305

Can we just check if grad is enabled before we call autograd.grad?

I do wonder whether we can have a more minimal repro though - will take a closer look tomorrow.

Chillee avatar Apr 20 '22 05:04 Chillee

Can we just check if grad is enabled before we call autograd.grad?

So silly of me. Yeah, fixed this.

I do wonder whether we can have a more minimal repro though - will take a closer look tomorrow.

Yes, I did not try super hard, but I could not come up in few min.

anijain2305 avatar Apr 20 '22 05:04 anijain2305