RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior

Traceback (most recent call last):
  File "infcomp_train.py", line 49, in <module>
    loss = csis.step()
  File "/ubc/cs/research/plai-scratch/virtuecc/venv/lib/python3.6/site-packages/pyro/infer/csis.py", line 69, in step
    loss = self.loss_and_grads(True, None, *args, **kwargs)
  File "/ubc/cs/research/plai-scratch/virtuecc/venv/lib/python3.6/site-packages/pyro/infer/csis.py", line 111, in loss_and_grads
    guide_grads = torch.autograd.grad(particle_loss, guide_params)
  File "/ubc/cs/research/plai-scratch/virtuecc/venv/lib/python3.6/site-packages/torch/autograd/__init__.py", line 157, in grad
    inputs, allow_unused)
RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior.

So this is more of a problem with PyTorch, but is there a way to set allowed_unused=True in the csis module so it doesn’t flow through PyTorch?

can you please provide more details about your setup?