Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Upgrade deprecated APIs in PyTorch 1.11 & clean out some legacy codes #1378

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/beanmachine/ppl/experimental/tests/gp/inference_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from beanmachine.ppl.experimental.gp import likelihoods
from beanmachine.ppl.experimental.gp.kernels import PeriodicKernel, ScaleKernel
from beanmachine.ppl.experimental.gp.models import SimpleGP
from beanmachine.ppl.legacy.inference import SingleSiteNoUTurnSampler
from gpytorch.distributions import MultivariateNormal


Expand Down Expand Up @@ -78,7 +77,7 @@ def test_simple_regression(self):
self.lengthscale_prior(),
self.period_length_prior(),
]
samples = SingleSiteNoUTurnSampler().infer(
samples = bm.SingleSiteNoUTurnSampler().infer(
queries, obs, n_samples, num_chains=1
)

Expand Down
3 changes: 1 addition & 2 deletions src/beanmachine/ppl/experimental/tests/gp/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import torch.distributions as dist
from beanmachine.ppl.experimental.gp import kernels, likelihoods
from beanmachine.ppl.experimental.gp.models import BoTorchGP, SimpleGP
from beanmachine.ppl.legacy.inference import SingleSiteNoUTurnSampler
from botorch.posteriors.gpytorch import GPyTorchPosterior


Expand All @@ -34,7 +33,7 @@ def mean():

def test_infer(self):
self.model.train()
SingleSiteNoUTurnSampler().infer([self.p()], {}, num_samples=2, num_chains=1)
bm.SingleSiteNoUTurnSampler().infer([self.p()], {}, num_samples=2, num_chains=1)

def test_load_and_predict(self):
self.model.eval()
Expand Down
2 changes: 1 addition & 1 deletion src/beanmachine/ppl/experimental/tests/vi/vi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def w():
def q_y():
weights = w()
data = x()
p = torch.sigmoid(data @ weights.T)
p = torch.sigmoid(data @ weights)
return dist.Bernoulli(p)

opt_params = VariationalInference().infer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ def get_proposal_distribution(self, world: World) -> dist.Distribution:
# flip(flip(H^-1)) = flip((L^-1)') @ flip(L^-1)
# H^-1 = flip(L^-1)' @ flip(L^-1)
# flip(L^-1)' is the lower triangular cholesky factor for H^-1.
L_inv = torch.triangular_solve(
torch.eye(L.size(-1)).to(dtype=neg_hessian.dtype, device=node_device),
L_inv = torch.linalg.solve_triangular(
L,
torch.eye(L.size(-1)).to(dtype=neg_hessian.dtype, device=node_device),
upper=False,
).solution
)
L_chol = L_inv.flip([0, 1]).T
distance = torch.cholesky_solve(first_gradient.unsqueeze(1), L).t()
proposal_args = _ProposalArgs(
Expand Down
15 changes: 0 additions & 15 deletions src/beanmachine/ppl/legacy/inference/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,18 @@
from beanmachine.ppl.legacy.inference.single_site_ancestral_mh import (
SingleSiteAncestralMetropolisHastings,
)
from beanmachine.ppl.legacy.inference.single_site_hamiltonian_monte_carlo import (
SingleSiteHamiltonianMonteCarlo,
)
from beanmachine.ppl.legacy.inference.single_site_newtonian_monte_carlo import (
SingleSiteNewtonianMonteCarlo,
)
from beanmachine.ppl.legacy.inference.single_site_no_u_turn_sampler import (
SingleSiteNoUTurnSampler,
)
from beanmachine.ppl.legacy.inference.single_site_random_walk import (
SingleSiteRandomWalk,
)
from beanmachine.ppl.legacy.inference.single_site_uniform_mh import (
SingleSiteUniformMetropolisHastings,
)


__all__ = [
"CompositionalInference",
"RejectionSampling",
"SingleSiteAncestralMetropolisHastings",
"SingleSiteHamiltonianMonteCarlo",
"SingleSiteNewtonianMonteCarlo",
"SingleSiteNoUTurnSampler",
"SingleSiteRandomWalk",
"SingleSiteUniformMetropolisHastings",
"Predictive",
"empirical",
"simulate",
]
8 changes: 0 additions & 8 deletions src/beanmachine/ppl/legacy/inference/proposer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,9 @@
from beanmachine.ppl.legacy.inference.proposer.single_site_newtonian_monte_carlo_proposer import (
SingleSiteNewtonianMonteCarloProposer,
)
from beanmachine.ppl.legacy.inference.proposer.single_site_no_u_turn_sampler_proposer import (
SingleSiteNoUTurnSamplerProposer,
)
from beanmachine.ppl.legacy.inference.proposer.single_site_uniform_proposer import (
SingleSiteUniformProposer,
)


__all__ = [
"SingleSiteAncestralProposer",
"SingleSiteNewtonianMonteCarloProposer",
"SingleSiteNoUTurnSamplerProposer",
"SingleSiteUniformProposer",
]
Loading