internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pyro-ppl/pyro

Issue:
Bug AffineCoupling
Hello,

There seems to be a bug in [here](https://github.com/pyro-ppl/pyro/blob/dev/pyro/distributions/transforms/affine_coupling.py#L106).

`mean, log_scale = self.arn(x1)`

should probably be

`mean, log_scale = self.hypernet(x1)`

instead, right?

Thanks in advance



Discussion:
@stefanwebb any idea why this isn't being caught by existing tests?
Let me look into this and add fix to #1932 

Resolving patch:
diff --git a/pyro/distributions/transforms/affine_coupling.py b/pyro/distributions/transforms/affine_coupling.py
--- a/pyro/distributions/transforms/affine_coupling.py
+++ b/pyro/distributions/transforms/affine_coupling.py
@@ -106,7 +106,7 @@ def _inverse(self, y):
         """
         y1, y2 = y[..., :self.split_dim], y[..., self.split_dim:]
         x1 = y1
-        mean, log_scale = self.arn(x1)
+        mean, log_scale = self.hypernet(x1)
         log_scale = clamp_preserve_gradients(log_scale, self.log_scale_min_clip, self.log_scale_max_clip)
         self._cached_log_scale = log_scale
 


Test patch:
diff --git a/tests/distributions/test_transforms.py b/tests/distributions/test_transforms.py
--- a/tests/distributions/test_transforms.py
+++ b/tests/distributions/test_transforms.py
@@ -131,6 +131,10 @@ def test_householder_inverses(self):
         for input_dim in [2, 5, 10]:
             self._test_inverse(input_dim, T.householder(input_dim, count_transforms=2))
 
+    def test_affine_coupling_inverses(self):
+        for input_dim in [2, 5, 10]:
+            self._test_inverse(input_dim, T.affine_coupling(input_dim))
+
     def test_lower_cholesky_affine(self):
         for input_dim in [2, 3]:
             loc = torch.randn(input_dim)
Repository: pyro-ppl/pyro

Issue:
ConditionedPlanarFlow's event_dim is wrong [bug]

--------------------------------------------------------------------------------------------------
### Issue Description
Provide a brief description of the issue.

I think the ConditionedPlanarFlow's event_dim is incorrect. I think the class needs to be set as such:
```

class ConditionedPlanarFlow(Transform):
   event_dim=1 #this line is not in the current release version
    def __init__(self, bias=None, u=None, w=None):
        super(ConditionedPlanarFlow, self).__init__(cache_size=1)
        self.bias = bias
        self.u = u
        self.w = w
        self._cached_logDetJ = None

```
The Transform super class default is event_dim=0.

Maybe I misunderstand this class, but I notice the PlanarFlow class has event_dim=1, as do many of the other normalizing flows and when I tried using this flow for my models my ELBO would go negative. I think the confusion is that ConditionalPlanarFlow has the event_dim=1, but that isn't setting it when it the actual flows are created (from what I can tell anyways).

### Environment
For any bugs, please provide the following:
 - Found on: Ubuntu 
 - PyTorch version: I think I was using 1.2 ...but again this is a super minor bug
You can see it in the the pyro docs http://docs.pyro.ai/en/stable/_modules/pyro/distributions/transforms/planar.html#ConditionalPlanarFlow

 - Pyro version: 3.6.10 (I think...pretty sure a single boolean value is pretty robust to version though)
Was originally found in...nightly build (not sure on term... I built from sourceb asically)




Discussion:
Thanks for picking this up! Will look into this and add to #1932 

Resolving patch:
diff --git a/pyro/distributions/transforms/planar.py b/pyro/distributions/transforms/planar.py
--- a/pyro/distributions/transforms/planar.py
+++ b/pyro/distributions/transforms/planar.py
@@ -14,6 +14,11 @@
 
 @copy_docs_from(Transform)
 class ConditionedPlanar(Transform):
+    domain = constraints.real
+    codomain = constraints.real
+    bijective = True
+    event_dim = 1
+
     def __init__(self, bias=None, u=None, w=None):
         super(ConditionedPlanar, self).__init__(cache_size=1)
         self.bias = bias


Test patch:
Repository: pyro-ppl/pyro

Issue:
pyro.deterministic RuntimeWarning when called outside of inference
From https://forum.pyro.ai/t/behaviour-of-pyro-deterministic/1570

`pyro.deterministic` should be able to be called outside of inference.


Discussion:
I think this should be resolved with #2214. I can take a look at that, if that seems like a reasonable solution. 

Resolving patch:
diff --git a/pyro/optim/dct_adam.py b/pyro/optim/dct_adam.py
--- a/pyro/optim/dct_adam.py
+++ b/pyro/optim/dct_adam.py
@@ -1,3 +1,6 @@
+# Copyright Contributors to the Pyro project.
+# SPDX-License-Identifier: Apache-2.0
+
 import math
 
 import torch
diff --git a/pyro/primitives.py b/pyro/primitives.py
--- a/pyro/primitives.py
+++ b/pyro/primitives.py
@@ -81,7 +81,7 @@ def sample(name, fn, *args, **kwargs):
     # check if stack is empty
     # if stack empty, default behavior (defined here)
     if not am_i_wrapped():
-        if obs is not None:
+        if obs is not None and not infer.get("_deterministic"):
             warnings.warn("trying to observe a value outside of inference at " + name,
                           RuntimeWarning)
             return obs
@@ -145,7 +145,8 @@ def deterministic(name, value, event_dim=None):
     :param int event_dim: Optional event dimension, defaults to `value.ndim`.
     """
     event_dim = value.ndim if event_dim is None else event_dim
-    return sample(name, dist.Delta(value, event_dim=event_dim).mask(False), obs=value)
+    return sample(name, dist.Delta(value, event_dim=event_dim).mask(False),
+                  obs=value, infer={"_deterministic": True})
 
 
 class plate(PlateMessenger):


Test patch:
diff --git a/tests/test_primitives.py b/tests/test_primitives.py
new file mode 100644
--- /dev/null
+++ b/tests/test_primitives.py
@@ -0,0 +1,33 @@
+# Copyright Contributors to the Pyro project.
+# SPDX-License-Identifier: Apache-2.0
+
+import pytest
+import pyro
+import pyro.distributions as dist
+import torch
+
+pytestmark = pytest.mark.stage('unit')
+
+
+def test_sample_ok():
+    x = pyro.sample("x", dist.Normal(0, 1))
+    assert isinstance(x, torch.Tensor)
+    assert x.shape == ()
+
+
+def test_observe_warn():
+    with pytest.warns(RuntimeWarning):
+        pyro.sample("x", dist.Normal(0, 1),
+                    obs=torch.tensor(0.))
+
+
+def test_param_ok():
+    x = pyro.param("x", torch.tensor(0.))
+    assert isinstance(x, torch.Tensor)
+    assert x.shape == ()
+
+
+def test_deterministic_ok():
+    x = pyro.deterministic("x", torch.tensor(0.))
+    assert isinstance(x, torch.Tensor)
+    assert x.shape == ()
Repository: pyro-ppl/pyro

Issue:
Switch from pillow to pillow-simd
This attempts to fix some `pillow`-`torchvision` breakage blocking #2239 by switching to the alternative torchvision-recommended library `pillow-simd`.


Discussion:
@fritzo - Thanks for fixing! Is this good to merge?
Ready to merge, feel free to change the label!

On Thu, Jan 2, 2020, 3:44 PM Neeraj Pradhan <notifications@github.com>
wrote:

> @fritzo
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_fritzo&d=DwMCaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=gqbaIgygRFx4F_iyVj0v-w&m=cBuF0Z5BQ108ArmUqSrOlho7lV4k6UpQN6umpXkYA-k&s=JGySNTzZWB_pKiBSGjOPIPce-1R4HRN-7xvhGyVSFbA&e=>
> - Thanks for fixing! Is this good to merge?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_pyro-2Dppl_pyro_pull_2240-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAAE6KVDU5XDNYWLR4DPG5JLQ3ZG3HA5CNFSM4KCF6FHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH7LI2Y-23issuecomment-2D570340459&d=DwMCaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=gqbaIgygRFx4F_iyVj0v-w&m=cBuF0Z5BQ108ArmUqSrOlho7lV4k6UpQN6umpXkYA-k&s=bogZl8n8v_GRNeC78g9J13BNBlFxErborBZmIWa7jPE&e=>,
> or unsubscribe
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AAE6KVAXNIVQFDB2GDJINPDQ3ZG3HANCNFSM4KCF6FHA&d=DwMCaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=gqbaIgygRFx4F_iyVj0v-w&m=cBuF0Z5BQ108ArmUqSrOlho7lV4k6UpQN6umpXkYA-k&s=YG5wz8hjVzgpT15k9xDiTZYAflb5kg4mBy-W77XYzcA&e=>
> .
>

I have filed a bug upstream at https://github.com/pytorch/vision/issues/1726

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -60,7 +60,6 @@
     'jupyter>=1.0.0',
     'graphviz>=0.8',
     'matplotlib>=1.3',
-    'pillow-simd',
     'torchvision>=0.5.0',
     'visdom>=0.1.4',
     'pandas',


Test patch:
Repository: pyro-ppl/pyro

Issue:
Forecasting I tutorial fails on Windows, no bunzip2
Hi,
I have just downloaded the Pytorch 1.4 and Pyro 1.3 to new environment Python 3.7 (Anaconda). The Forecasting I tutorial fails, on line
dataset = load_bart_od()
with message:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "D:\progs2\anaconda3\envs\pyro13\lib\site-packages\pyro\contrib\examples\bart.py", line 125, in load_bart_od
    subprocess.check_call(["bunzip2", "-k", filename])
  File "D:\progs2\anaconda3\envs\pyro13\lib\subprocess.py", line 358, in check_call
    retcode = call(*popenargs, **kwargs)
  File "D:\progs2\anaconda3\envs\pyro13\lib\subprocess.py", line 339, in call
    with Popen(*popenargs, **kwargs) as p:
  File "D:\progs2\anaconda3\envs\pyro13\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "D:\progs2\anaconda3\envs\pyro13\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

Regards,
Slawek


Discussion:

Resolving patch:
diff --git a/pyro/contrib/examples/bart.py b/pyro/contrib/examples/bart.py
--- a/pyro/contrib/examples/bart.py
+++ b/pyro/contrib/examples/bart.py
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: Apache-2.0
 
 import argparse
+import bz2
 import csv
 import datetime
 import logging
@@ -122,7 +123,8 @@ def load_bart_od():
         try:
             urllib.request.urlretrieve(CACHE_URL, filename)
             logging.debug("cache hit, uncompressing")
-            subprocess.check_call(["bunzip2", "-k", filename])
+            with bz2.BZ2File(filename) as src, open(filename[:-4], "wb") as dst:
+                dst.write(src.read())
         except urllib.error.HTTPError:
             logging.debug("cache miss, preprocessing from scratch")
     if os.path.exists(pkl_file):


Test patch:
Repository: pyro-ppl/pyro

Issue:
[bug] pyro.distributions.InverseGamma.sample does not work on GPU
### Issue Description
`pyro.distributions.InverseGamma.sample` fails with the following error when its arguments are on the GPU:
```
RuntimeError: iter.device(arg).is_cuda() INTERNAL ASSERT FAILED at /pytorch/aten/src/ATen/native/cuda/Loops.cuh:197, please report a bug to PyTorch.
```

I think the problem is in `__init__`:
```python
    def __init__(self, concentration, rate, validate_args=None):
        base_dist = Gamma(concentration, rate)
        super().__init__(base_dist, PowerTransform(-1.0), validate_args=validate_args)
```
The argument to `PowerTransform` should probably be something like `-torch.ones_like(rate)`.

### Environment
Ubuntu 16.04, Python 3.7, PyTorch 1.4.0, Pyro 1.3.0

### Code Snippet
```python
>>> import torch
>>> from pyro.distributions import Gamma, InverseGamma, TransformedDistribution
>>> from pyro.distributions.transforms import PowerTransform
>>>
>>> concentration = torch.tensor(1.0).to("cuda")
>>> rate = torch.tensor(1.0).to("cuda")
>>> 
>>> # InverseGamma.sample fails with an error
>>> InverseGamma(concentration, rate).sample()
RuntimeError: iter.device(arg).is_cuda() INTERNAL ASSERT FAILED at /pytorch/aten/src/ATen/native/cuda/Loops.cuh:197, please report a bug to PyTorch.
>>> 
>>> # The equivalent TransformedDistribution is fine
>>> TransformedDistribution(
...     Gamma(concentration, rate),
...     PowerTransform(torch.tensor(-1.0).to("cuda")),
... ).sample()
tensor(0.5707, device='cuda:0')
```


Discussion:
Good catch, you can probably work around via `torch.set_default_tensor_type("torch.cuda.FloatTensor")` for now.

Resolving patch:
diff --git a/pyro/distributions/inverse_gamma.py b/pyro/distributions/inverse_gamma.py
--- a/pyro/distributions/inverse_gamma.py
+++ b/pyro/distributions/inverse_gamma.py
@@ -23,7 +23,8 @@ class InverseGamma(TransformedDistribution):
 
     def __init__(self, concentration, rate, validate_args=None):
         base_dist = Gamma(concentration, rate)
-        super().__init__(base_dist, PowerTransform(-1.0), validate_args=validate_args)
+        super().__init__(base_dist, PowerTransform(-base_dist.rate.new_ones(())),
+                         validate_args=validate_args)
 
     def expand(self, batch_shape, _instance=None):
         new = self._get_checked_instance(InverseGamma, _instance)


Test patch:
Repository: pyro-ppl/pyro

Issue:
[bug] Samples from LKJCorrCholesky have the wrong shape
### Issue Description
The batch and sample shapes for `LKJCorrCholesky` are swapped when sampling.

### Environment
OS: Ubuntu 16.04
Python: 3.7.2
Torch version: 1.6.0
Pyro version: 1.4.0

### Code Snippet
Minimal example:

```python
>>> dist = pyro.distributions.LKJCorrCholesky(d=3, eta=torch.ones(())).expand(12)
>>> # batch shape and event shape are as you'd expect
>>> dist.batch_shape
torch.Size([12])
>>> dist.event_shape
torch.Size([3, 3])
>>> # samples have correct shape when sample_shape=()
>>> dist.shape(())
torch.Size([12, 3, 3])
>>> dist.sample().shape
torch.Size([12, 3, 3])
>>> # samples have the wrong shape when sample_shape is non-unit
>>> dist.shape((4,))  # as expected
torch.Size([4, 12, 3, 3])
>>> dist.sample((4,)).shape
torch.Size([12, 4, 3, 3])
```

I think this line is the culprit: https://github.com/pyro-ppl/pyro/blob/7c2c22c10dffda8a33ffbd593cc8d58819959e40/pyro/distributions/lkj.py#L67

```python
    def sample(self, sample_shape=torch.Size()):
        y = self._gen.sample(sample_shape=self.batch_shape + sample_shape).detach()
        z = y.mul(2).add(-1.0)
        return _vector_to_l_cholesky(z)
```

should be 

```python
    def sample(self, sample_shape=torch.Size()):
        y = self._gen.sample(sample_shape=sample_shape + self.batch_shape).detach()
        z = y.mul(2).add(-1.0)
        return _vector_to_l_cholesky(z)
```



Discussion:

Resolving patch:
diff --git a/pyro/distributions/lkj.py b/pyro/distributions/lkj.py
--- a/pyro/distributions/lkj.py
+++ b/pyro/distributions/lkj.py
@@ -64,7 +64,8 @@ def __init__(self, d, eta, validate_args=None):
         super().__init__(torch.Size(), torch.Size((d, d)), validate_args=validate_args)
 
     def sample(self, sample_shape=torch.Size()):
-        y = self._gen.sample(sample_shape=self.batch_shape + sample_shape).detach()
+        with torch.no_grad():
+            y = self._gen.sample(sample_shape=sample_shape + self.batch_shape)
         z = y.mul(2).add(-1.0)
         return _vector_to_l_cholesky(z)
 


Test patch:
diff --git a/tests/distributions/test_lkj.py b/tests/distributions/test_lkj.py
--- a/tests/distributions/test_lkj.py
+++ b/tests/distributions/test_lkj.py
@@ -109,3 +109,17 @@ def test_log_prob_d2(eta):
     tst = test_dist.log_prob(x)
 
     assert_tensors_equal(lp, tst, prec=1e-6)
+
+
+def test_sample_batch():
+    # Regression test for https://github.com/pyro-ppl/pyro/issues/2615
+    dist = LKJCorrCholesky(d=3, eta=torch.ones(())).expand([12])
+    # batch shape and event shape are as you'd expect
+    assert dist.batch_shape == torch.Size([12])
+    assert dist.event_shape == torch.Size([3, 3])
+    # samples have correct shape when sample_shape=()
+    assert dist.shape(()) == torch.Size([12, 3, 3])
+    assert dist.sample().shape == torch.Size([12, 3, 3])
+    # samples had the wrong shape when sample_shape is non-unit
+    assert dist.shape((4,)) == torch.Size([4, 12, 3, 3])
+    assert dist.sample((4,)).shape == torch.Size([4, 12, 3, 3])
Repository: pyro-ppl/pyro

Issue:
Elbo.compute_marginals throws an error for basic model
As @Bart mentioned in this forum question :
https://forum.pyro.ai/t/elbo-compute-marginals-throws-an-error-for-basic-model/2245

When observed variables has no enumerated ancestors, this error of compute_marginals will arise:
"ValueError: Number of einsum subscripts must be equal to the number of operands."

Now this error can be fixed by adding a dummy upstream discrete node, but a formal fix is needed.


Discussion:
copying the minimum working example from the forum:

<details>

```py
@config_enumerate()
def model(a=None, b=None):
    a = sample("a", dist.Bernoulli(0.75), obs=a)
    p = 1-0.25*a
    b = sample("b", dist.Bernoulli(p), obs=b)

elbo = pyro.infer.TraceEnum_ELBO()

# This works.
elbo.compute_marginals(model, guide, b=tt(1.))

# These fail.
elbo.compute_marginals(model, guide, a=tt(1.))
elbo.compute_marginals(model, guide)
```

</details>

Resolving patch:
diff --git a/pyro/infer/traceenum_elbo.py b/pyro/infer/traceenum_elbo.py
--- a/pyro/infer/traceenum_elbo.py
+++ b/pyro/infer/traceenum_elbo.py
@@ -133,15 +133,13 @@ def _compute_model_factors(model_trace, guide_trace):
                 cost = site["packed"]["masked_log_prob"]
                 log_factors.setdefault(t, []).append(cost)
                 scales.append(site["scale"])
-    if log_factors:
-        for t, sites_t in enum_sites.items():
-            # TODO refine this coarse dependency ordering using time and tensor shapes.
-            if any(t <= u for u in log_factors):
-                for site in sites_t:
-                    logprob = site["packed"]["unscaled_log_prob"]
-                    log_factors.setdefault(t, []).append(logprob)
-                    scales.append(site["scale"])
-        scale = _get_common_scale(scales)
+    for t, sites_t in enum_sites.items():
+        # TODO refine this coarse dependency ordering using time and tensor shapes.
+        for site in sites_t:
+            logprob = site["packed"]["unscaled_log_prob"]
+            log_factors.setdefault(t, []).append(logprob)
+            scales.append(site["scale"])
+    scale = _get_common_scale(scales)
     return marginal_costs, log_factors, ordering, enum_dims, scale
 
 


Test patch:
diff --git a/tests/infer/test_enum.py b/tests/infer/test_enum.py
--- a/tests/infer/test_enum.py
+++ b/tests/infer/test_enum.py
@@ -3074,6 +3074,22 @@ def guide(data):
         assert d1.probs[1] < d2.probs[1]
 
 
+@pytest.mark.parametrize("observed", ["", "a", "b", "ab"])
+def test_marginals_2678(observed):
+
+    @config_enumerate
+    def model(a=None, b=None):
+        a = pyro.sample("a", dist.Bernoulli(0.75), obs=a)
+        pyro.sample("b", dist.Bernoulli(1 - 0.25 * a), obs=b)
+
+    def guide(a=None, b=None):
+        pass
+
+    kwargs = {name: torch.tensor(1.) for name in observed}
+    elbo = TraceEnum_ELBO(strict_enumeration_warning=False)
+    elbo.compute_marginals(model, guide, **kwargs)
+
+
 @pytest.mark.parametrize("data", [
     [None, None],
     [torch.tensor(0.), None],
Repository: pyro-ppl/pyro

Issue:
Init signature does not appear for distribution class
Currently, when creating an instance of `dist.Normal` in jupyter, the docstring will say
```
Init signature: dist.Normal(*args, **kwargs)
```
That infomation is not helpful. This new behavior happens because we define `DistributionMeta.__call__` for collapse messenger. It would be nice to find an alternative solution that preserves the signature of distributions' constructors.


Discussion:
Thanks for pointing this out, I'll look into it.
It looks like we'll need to get `inspect.signature(Normal)` to print the more informative string, since that's [what help() uses](https://github.com/python/cpython/blob/4173320920706b49a004bdddd8d7108e8984e3fc/Lib/pydoc.py#L1321). Here's a minimal working example:
```sh
python -c 'import pyro.distributions as d, inspect as i; print(i.signature(d.Normal))'
```
```
(*args, **kwargs)
```

Resolving patch:
diff --git a/pyro/distributions/distribution.py b/pyro/distributions/distribution.py
--- a/pyro/distributions/distribution.py
+++ b/pyro/distributions/distribution.py
@@ -1,6 +1,7 @@
 # Copyright (c) 2017-2019 Uber Technologies, Inc.
 # SPDX-License-Identifier: Apache-2.0
 
+import functools
 from abc import ABCMeta, abstractmethod
 
 from pyro.distributions.score_parts import ScoreParts
@@ -16,6 +17,10 @@ def __call__(cls, *args, **kwargs):
                 return result
         return super().__call__(*args, **kwargs)
 
+    @property
+    def __wrapped__(cls):
+        return functools.partial(cls.__init__, None)
+
 
 class Distribution(metaclass=DistributionMeta):
     """


Test patch:
Repository: pyro-ppl/pyro

Issue:
PyroModule.requires_grad_(False).__call__() issues unwanted warning
After training a `PyroModule` model, I'd like to detach it and use it elsewhere in a "frozen" state. One obvious way to do so would be to call `my_module.requires_grad_(False)` to detach all parameters. Doing so results in the desired behavior, but has the side effect of triggering the following warning (many many times):
```
/Users/fobermey/github/pyro-ppl/pyro/pyro/primitives.py:361: UserWarning: linear.bias was not registered in the param store because requires_grad=False
  " requires_grad=False")
```

It is unclear to me how to resolve this. Should we provide a `detach_()` method for modules that converts all `PyroParam`s to `Tensor`s? Should we simply remove that warning if it occurs in a `PyroModule`? Should we be calling some other method like `my_module.train(False)`?


Discussion:

Resolving patch:
diff --git a/pyro/primitives.py b/pyro/primitives.py
--- a/pyro/primitives.py
+++ b/pyro/primitives.py
@@ -356,9 +356,10 @@ def module(name, nn_module, update_module_params=False):
 
             if param_value._cdata != returned_param._cdata:
                 target_state_dict[param_name] = returned_param
-        else:
-            warnings.warn("{} was not registered in the param store because".format(param_name) +
-                          " requires_grad=False")
+        elif nn_module.training:
+            warnings.warn(f"{param_name} was not registered in the param store "
+                          "because requires_grad=False. You can silence this "
+                          "warning by calling my_module.train(False)")
 
     if target_state_dict and update_module_params:
         # WARNING: this is very dangerous. better method?


Test patch:
Repository: pyro-ppl/pyro

Issue:
Upgrade to PyTorch 1.8
This documents our upgrade plan to PyTorch 1.8, which breaks `pyro.distributions` as in Pyro 1.5.1 release. PyTorch 1.8.0 release is scheduled for sometime in March 2021.

## Plan

- [x] #2755 Release Pyro 1.5.2 which constrains to `torch<=1.7.2`.
- [x] #2757 Upgrade dev branch to PyTorch 1.7.0, fixing tests.
- [x] #2753 Pin Pyro dev branch to PyTorch nightly build, and fix many breaking changes.
- [x] #2739 Implement `Distribution.infer_shapes()`.
- ...
- [ ] After PyTorch 1.8 release, pin Pyro dev back to PyTorch release and release Pyro 1.6.

cc @neerajprad 


Discussion:

Resolving patch:
diff --git a/docs/source/conf.py b/docs/source/conf.py
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -213,8 +213,5 @@ def setup(app):
 # See similar line in the install section of .travis.yml
 if 'READTHEDOCS' in os.environ:
     os.system('pip install numpy')
-    # TODO replace with torch_stable before release
-    # os.system('pip install torch==1.8.0+cpu torchvision==0.9.0+cpu '
-    #           '-f https://download.pytorch.org/whl/torch_stable.html')
-    os.system('pip install torch==1.8.0+cpu torchvision==0.9.0 '
-              '-f https://download.pytorch.org/whl/test/cpu/torch_test.html')
+    os.system('pip install torch==1.8.0+cpu torchvision==0.9.0+cpu '
+              '-f https://download.pytorch.org/whl/torch_stable.html')


Test patch: