Conversation
|
Thank you, Yerdos! |
Preinstall visdom without build isolation to avoid pkg_resources failures on modern setuptools, require explicit context in ConditionalAutoRegressiveNN, and replace cast-based mypy suppressions with type ignores.
|
@ordabayevy thanks! what else needs to be done here to merge? |
|
There are unit tests that are failing due to the new PyTorch version. I will try to get them fixed today. |
ordabayevy
left a comment
There was a problem hiding this comment.
@fritzo @martinjankowiak ready for a review!
| run: | | ||
| python -m pip install --upgrade pip wheel setuptools | ||
| pip install ruff black mypy nbstripout nbformat | ||
| pip install -e . |
There was a problem hiding this comment.
Added this so that the type checker can get dependency libraries stubs.
| pyro-api>=0.1.1 | ||
| tqdm>=4.36 | ||
| funsor[torch] | ||
| funsor[torch] @ git+https://github.com/pyro-ppl/funsor.git@8a8ca81fcc61733ad82e163028c7ff78420df9f0 |
There was a problem hiding this comment.
Will be pinned to a released funsor version before pyro release.
|
|
||
| # Viz sample from prior. | ||
| if args.viz: | ||
| import visdom |
There was a problem hiding this comment.
Visdom is not actively supported - made the import lazy.
There was a problem hiding this comment.
should we just replace this with some matplotlib equivalent?
There was a problem hiding this comment.
In another PR? This one already has a lot of changes
| test_data = torch.tensor( | ||
| pd_dataframe[["SeasonAt-Bats", "SeasonHits"]].values, | ||
| dtype=torch.float, | ||
| device=device, |
There was a problem hiding this comment.
The constructor should use the default device so no need to pass it.
| permutation = torch.randperm(channels, device="cpu").to( | ||
| torch.Tensor().device | ||
| ) | ||
| permutation = torch.randperm(channels) |
| log_det = gpytorch.lazy.NonLazyTensor(truncated).logdet() | ||
| except ImportError: | ||
| log_det = torch.linalg.cholesky(truncated).diag().log().sum() * 2 | ||
| log_det = torch.linalg.cholesky(truncated).diag().log().sum() * 2 |
There was a problem hiding this comment.
NonLazyTensor doesn't exist in new gpytorch releases.
| def integrate(fn, domain): | ||
| sl = [slice(None)] + (len(domain.shape) - 1) * [None] | ||
| half_roots_sl = half_roots[sl] | ||
| half_roots_sl = half_roots[tuple(sl)] |
There was a problem hiding this comment.
In new pytorch releases list of tensors index gets wrapped in torch.tensor().
|
|
||
| @staticmethod | ||
| def infer_shapes(low, high): | ||
| return torch.Size(broadcast_shape(low, high)), torch.Size() |
There was a problem hiding this comment.
Superclass infer_shapes relies on cls.arg_constraints but in new pytorch Uniform.arg_constraints became an instance property.
| assert chain_id < self.num_chains | ||
| self.exec_traces.append(tr) | ||
| self.log_weights.append(logit) | ||
| self.log_weights.append(torch.as_tensor(logit).detach()) |
There was a problem hiding this comment.
The old torch.tensor(self.log_weights) would remove grads and emit warning so detaching here should be okay?
| alpha_atol = 0.1 if alpha_near_one else 0.04 | ||
| beta_atol = 0.12 if alpha_near_one else 0.06 | ||
| assert_close(alpha, pyro.param("alpha").item(), atol=alpha_atol) | ||
| assert_close(beta, pyro.param("beta").item(), atol=beta_atol) |
There was a problem hiding this comment.
Had to increase tolerance for tests to pass.
There was a problem hiding this comment.
because of your precision change?
There was a problem hiding this comment.
I don't think so because torch.as_tensor should return double but I'm re-running the stricter test with explicit double() to verify.
There was a problem hiding this comment.
It fails with explicit double() too
|
|
||
| # Viz sample from prior. | ||
| if args.viz: | ||
| import visdom |
There was a problem hiding this comment.
should we just replace this with some matplotlib equivalent?
| roots, weights = roots_legendre(num_points) | ||
| roots = torch.Tensor(roots).double() | ||
| weights = torch.Tensor(weights).double() | ||
| roots = torch.as_tensor(roots) |
There was a problem hiding this comment.
roots_legendre returns float64 and torch.as_tensor preserves the double dtype.
| alpha_atol = 0.1 if alpha_near_one else 0.04 | ||
| beta_atol = 0.12 if alpha_near_one else 0.06 | ||
| assert_close(alpha, pyro.param("alpha").item(), atol=alpha_atol) | ||
| assert_close(beta, pyro.param("beta").item(), atol=beta_atol) |
There was a problem hiding this comment.
because of your precision change?
|
I don't remember having the DCO check before. Was it enabled automatically? Do I have to sign and push a commit? |
|
not sure about DCO. but yeah try signing your commit... |
Signed-off-by: Yerdos Ordabayev <yerdos2030@gmail.com>
|
thanks yerdos! |
Main Changes
CI/tooling compatibility
CC=gcc-9/CXX=g++-9from GitHub Actions so PyTorch C++ extensions can use a newer runner compiler.--warn-unused-ignorestomake lint.3.9to3.10.pytest-benchmarkintest-funsorbecause it warns underxdist, and warnings are errors.Dependency cleanup
visdomfrom broad extras/test dependencies.funsor[torch]to the remote fixed commit insetup.pyanddocs/requirements.txt.PyTorch compatibility fixes
Uniform.infer_shapes()to avoid newer Torch’s property-backedarg_constraintsissue.lazy_property.__call__patch that was causing inspect/doctest issues with newer Torch.Typing/lint cleanup
type: ignorecomments now caught by--warn-unused-ignores.Other cleanup
gpytorch.lazy.NonLazyTensorpath inSpanningTree.log_partition_function, usingtorch.linalg.choleskydirectly.Why
The branch mainly makes the project work with newer PyTorch/tooling: PyTorch changed
arg_constraints, warns on list indexing and tensor scalar conversion, and now requires a newer C++ compiler path for extensions. It also reduces CI fragility by removing Visdom from the default test dependency set and tightening lint so stale ignores don’t accumulate.