Hi,
Do you set requires_grad afterwards for some reason on the params of gan.D ?
Are you sure that your function is twice differentiable with respect to your parameters (and non-zero) though?
What happens if for the sake of the experiment you do bce = bce.exp() to ensure the function is properly differentiable?