What happened?
botorch.posteriors.gpytorch.GPyTorchPosterior.distribution can hold distributions that are not MultivariateNormal, including Beta and Bernoulli distributions, depending on the model likelihood.
For instance with a SingleTaskVariationalGP with BetaLikelihood, the posterior with observation noise has a Beta distribution. Is GPyTorchPosterior meant to work with Beta posterior? If the type hint below is correct, it follows that GPyTorchPosterior would be the incorrect class for a Beta posterior distribution? https://github.com/meta-pytorch/botorch/blob/5818db266d09c39b3b9f90bc7b13924939c1661b/botorch/posteriors/gpytorch.py#L38
Please provide a minimal, reproducible example of the unexpected behavior.
import torch
from botorch.models.approximate_gp import SingleTaskVariationalGP
from gpytorch.distributions import MultivariateNormal
from gpytorch.likelihoods import BetaLikelihood
train_X = torch.rand((20, 10), dtype=torch.double)
train_Y = torch.rand((20, 1), dtype=torch.double)
model = SingleTaskVariationalGP(
train_X,
train_Y,
likelihood=BetaLikelihood(),
)
posterior = model.posterior(train_X, observation_noise=True)
print(f"`posterior` is of type {type(posterior)}")
print(f"Posterior distribution is of type {type(posterior.distribution)}")
print(f"posterior.distribution is an instance of MultivariateNormal: {isinstance(posterior.distribution, MultivariateNormal)}")
Please paste any relevant traceback/logs produced by the example provided.
miniconda3/envs/botorch/lib/python3.12/site-packages/botorch/models/utils/assorted.py:274: InputDataWarning: Data (outcome observations) is not standardized (std = tensor([0.2552], dtype=torch.float64), mean = tensor([0.4533], dtype=torch.float64)).Please consider scaling the input to zero mean and unit variance.
check_standardization(Y=train_Y, raise_on_fail=raise_on_fail)
`posterior` is of type <class 'botorch.posteriors.gpytorch.GPyTorchPosterior'>
Posterior distribution is of type <class 'pyro.distributions.torch.Beta'>
posterior.distribution is an instance of MultivariateNormal: False
BoTorch Version
0.16.0
Python Version
3.12.12
Operating System
macOS 26.0.1
(Optional) Describe any potential fixes you've considered to the issue outlined above.
Update the type hint
Pull Request
Yes
Code of Conduct
What happened?
botorch.posteriors.gpytorch.GPyTorchPosterior.distributioncan hold distributions that are notMultivariateNormal, including Beta and Bernoulli distributions, depending on the model likelihood.For instance with a
SingleTaskVariationalGPwithBetaLikelihood, the posterior with observation noise has a Beta distribution. IsGPyTorchPosteriormeant to work withBetaposterior? If the type hint below is correct, it follows thatGPyTorchPosteriorwould be the incorrect class for a Beta posterior distribution? https://github.com/meta-pytorch/botorch/blob/5818db266d09c39b3b9f90bc7b13924939c1661b/botorch/posteriors/gpytorch.py#L38Please provide a minimal, reproducible example of the unexpected behavior.
Please paste any relevant traceback/logs produced by the example provided.
BoTorch Version
0.16.0
Python Version
3.12.12
Operating System
macOS 26.0.1
(Optional) Describe any potential fixes you've considered to the issue outlined above.
Update the type hint
Pull Request
Yes
Code of Conduct