When generating samples using pyro.infer.predictive.Predictive, gradients are dropped. It looks like this is an intentional design choice from the code, but I'm not sure why - if there's a good reason then ignore me.
Code Snippet
Create a model and fit a guide such that model(x).requires_grad and guide(x)['some_site'].requires_grad both return True when x has gradients enabled. Then do:
Issue Description
When generating samples using pyro.infer.predictive.Predictive, gradients are dropped. It looks like this is an intentional design choice from the code, but I'm not sure why - if there's a good reason then ignore me.
Code Snippet
Create a model and fit a guide such that
model(x).requires_grad
andguide(x)['some_site'].requires_grad
both return True whenx
has gradients enabled. Then do:Then
posterior_samples['some_site'].requires_grad
is False.