google-research / torchsde

Differentiable SDE solvers with GPU support and efficient sensitivity analysis.
Apache License 2.0
1.52k stars 195 forks source link

Workaround PyTorch bug #39784 #11

Closed patrick-kidger closed 3 years ago

patrick-kidger commented 3 years ago

PyTorch has a bug when differentiating wrt unused inputs: https://github.com/pytorch/pytorch/issues/39784

If there are unused inputs that are unused globally, then it will backprop through the whole graph, even unrelated components. As such using the allow_unused flag is dangerous without this workaround.