From 00b0cf82a883a15eeeedf32df41e59c660d69856 Mon Sep 17 00:00:00 2001 From: Winnie Zhang Date: Mon, 22 Aug 2022 09:04:53 -0700 Subject: [PATCH] Graduate VI from experimental (#1609) Summary: Pull Request resolved: https://github.com/facebookresearch/beanmachine/pull/1609 - Graduated VI from experimental for the 0.2.0 release => moved it to `ppl/inference` - Used the reference tool to find all references of the classes/ functions that are being graduated Reviewed By: horizon-blue Differential Revision: D38875109 fbshipit-source-id: ce0bf9458ce91f032962dc42b725ab840d431eda --- src/beanmachine/ppl/experimental/tests/vi/__init__.py | 0 .../tests/vi => inference/tests}/vi_gpu_test.py | 2 +- .../{experimental/tests/vi => inference/tests}/vi_test.py | 8 +++----- .../ppl/{experimental => inference}/vi/__init__.py | 0 .../ppl/{experimental => inference}/vi/autoguide.py | 4 ++-- .../ppl/{experimental => inference}/vi/discrepancy.py | 0 .../{experimental => inference}/vi/gradient_estimator.py | 2 +- .../{experimental => inference}/vi/variational_infer.py | 6 +++--- .../{experimental => inference}/vi/variational_world.py | 0 src/beanmachine/ppl/model/statistical_model.py | 2 +- 10 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 src/beanmachine/ppl/experimental/tests/vi/__init__.py rename src/beanmachine/ppl/{experimental/tests/vi => inference/tests}/vi_gpu_test.py (96%) rename src/beanmachine/ppl/{experimental/tests/vi => inference/tests}/vi_test.py (98%) rename src/beanmachine/ppl/{experimental => inference}/vi/__init__.py (100%) rename src/beanmachine/ppl/{experimental => inference}/vi/autoguide.py (96%) rename src/beanmachine/ppl/{experimental => inference}/vi/discrepancy.py (100%) rename src/beanmachine/ppl/{experimental => inference}/vi/gradient_estimator.py (98%) rename src/beanmachine/ppl/{experimental => inference}/vi/variational_infer.py (96%) rename src/beanmachine/ppl/{experimental => inference}/vi/variational_world.py (100%) diff --git a/src/beanmachine/ppl/experimental/tests/vi/__init__.py b/src/beanmachine/ppl/experimental/tests/vi/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/beanmachine/ppl/experimental/tests/vi/vi_gpu_test.py b/src/beanmachine/ppl/inference/tests/vi_gpu_test.py similarity index 96% rename from src/beanmachine/ppl/experimental/tests/vi/vi_gpu_test.py rename to src/beanmachine/ppl/inference/tests/vi_gpu_test.py index f3574979a9..7813b91ece 100644 --- a/src/beanmachine/ppl/experimental/tests/vi/vi_gpu_test.py +++ b/src/beanmachine/ppl/inference/tests/vi_gpu_test.py @@ -9,7 +9,7 @@ import pytest import torch import torch.distributions as dist -from beanmachine.ppl.experimental.vi import VariationalInfer +from beanmachine.ppl.inference.vi import VariationalInfer cpu_device = torch.device("cpu") diff --git a/src/beanmachine/ppl/experimental/tests/vi/vi_test.py b/src/beanmachine/ppl/inference/tests/vi_test.py similarity index 98% rename from src/beanmachine/ppl/experimental/tests/vi/vi_test.py rename to src/beanmachine/ppl/inference/tests/vi_test.py index 01c10a6bb2..31e6043183 100644 --- a/src/beanmachine/ppl/experimental/tests/vi/vi_test.py +++ b/src/beanmachine/ppl/inference/tests/vi_test.py @@ -12,11 +12,9 @@ import scipy.stats import torch import torch.distributions as dist -from beanmachine.ppl.experimental.vi import ADVI, MAP, VariationalInfer -from beanmachine.ppl.experimental.vi.gradient_estimator import ( - monte_carlo_approximate_sf, -) -from beanmachine.ppl.experimental.vi.variational_world import VariationalWorld +from beanmachine.ppl.inference.vi import ADVI, MAP, VariationalInfer +from beanmachine.ppl.inference.vi.gradient_estimator import monte_carlo_approximate_sf +from beanmachine.ppl.inference.vi.variational_world import VariationalWorld from beanmachine.ppl.world import init_from_prior, RVDict from torch import optim from torch.distributions import constraints diff --git a/src/beanmachine/ppl/experimental/vi/__init__.py b/src/beanmachine/ppl/inference/vi/__init__.py similarity index 100% rename from src/beanmachine/ppl/experimental/vi/__init__.py rename to src/beanmachine/ppl/inference/vi/__init__.py diff --git a/src/beanmachine/ppl/experimental/vi/autoguide.py b/src/beanmachine/ppl/inference/vi/autoguide.py similarity index 96% rename from src/beanmachine/ppl/experimental/vi/autoguide.py rename to src/beanmachine/ppl/inference/vi/autoguide.py index 71e8619650..a18a9f450b 100644 --- a/src/beanmachine/ppl/experimental/vi/autoguide.py +++ b/src/beanmachine/ppl/inference/vi/autoguide.py @@ -9,8 +9,8 @@ import torch from beanmachine import ppl as bm from beanmachine.ppl.distributions.delta import Delta -from beanmachine.ppl.experimental.vi.variational_infer import VariationalInfer -from beanmachine.ppl.experimental.vi.variational_world import VariationalWorld +from beanmachine.ppl.inference.vi.variational_infer import VariationalInfer +from beanmachine.ppl.inference.vi.variational_world import VariationalWorld from beanmachine.ppl.model.rv_identifier import RVIdentifier from beanmachine.ppl.world import RVDict from torch import distributions as dist diff --git a/src/beanmachine/ppl/experimental/vi/discrepancy.py b/src/beanmachine/ppl/inference/vi/discrepancy.py similarity index 100% rename from src/beanmachine/ppl/experimental/vi/discrepancy.py rename to src/beanmachine/ppl/inference/vi/discrepancy.py diff --git a/src/beanmachine/ppl/experimental/vi/gradient_estimator.py b/src/beanmachine/ppl/inference/vi/gradient_estimator.py similarity index 98% rename from src/beanmachine/ppl/experimental/vi/gradient_estimator.py rename to src/beanmachine/ppl/inference/vi/gradient_estimator.py index d1ac144a46..b6c4c7ac9a 100644 --- a/src/beanmachine/ppl/experimental/vi/gradient_estimator.py +++ b/src/beanmachine/ppl/inference/vi/gradient_estimator.py @@ -8,7 +8,7 @@ from typing import Callable, Mapping import torch -from beanmachine.ppl.experimental.vi.variational_world import VariationalWorld +from beanmachine.ppl.inference.vi.variational_world import VariationalWorld from beanmachine.ppl.model.rv_identifier import RVIdentifier from beanmachine.ppl.world import RVDict, World diff --git a/src/beanmachine/ppl/experimental/vi/variational_infer.py b/src/beanmachine/ppl/inference/vi/variational_infer.py similarity index 96% rename from src/beanmachine/ppl/experimental/vi/variational_infer.py rename to src/beanmachine/ppl/inference/vi/variational_infer.py index c993afe3a4..c3d6245af7 100644 --- a/src/beanmachine/ppl/experimental/vi/variational_infer.py +++ b/src/beanmachine/ppl/inference/vi/variational_infer.py @@ -10,11 +10,11 @@ import torch import torch.optim as optim -from beanmachine.ppl.experimental.vi.discrepancy import kl_reverse -from beanmachine.ppl.experimental.vi.gradient_estimator import ( +from beanmachine.ppl.inference.vi.discrepancy import kl_reverse +from beanmachine.ppl.inference.vi.gradient_estimator import ( monte_carlo_approximate_reparam, ) -from beanmachine.ppl.experimental.vi.variational_world import VariationalWorld +from beanmachine.ppl.inference.vi.variational_world import VariationalWorld from beanmachine.ppl.model.rv_identifier import RVIdentifier from beanmachine.ppl.world.world import RVDict from tqdm.auto import tqdm diff --git a/src/beanmachine/ppl/experimental/vi/variational_world.py b/src/beanmachine/ppl/inference/vi/variational_world.py similarity index 100% rename from src/beanmachine/ppl/experimental/vi/variational_world.py rename to src/beanmachine/ppl/inference/vi/variational_world.py diff --git a/src/beanmachine/ppl/model/statistical_model.py b/src/beanmachine/ppl/model/statistical_model.py index ea6efb6b4d..e06aacd836 100644 --- a/src/beanmachine/ppl/model/statistical_model.py +++ b/src/beanmachine/ppl/model/statistical_model.py @@ -8,7 +8,7 @@ import torch import torch.distributions as dist -from beanmachine.ppl.experimental.vi.variational_world import VariationalWorld +from beanmachine.ppl.inference.vi.variational_world import VariationalWorld from beanmachine.ppl.legacy.world import World from beanmachine.ppl.model.rv_identifier import RVIdentifier from beanmachine.ppl.world import get_world_context