Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for observation noise without mask in ModelListGP #2735

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

swierh
Copy link

@swierh swierh commented Feb 6, 2025

Motivation

Fixes #2734

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

I've added a test to the unit test, in addition, a separate example:

import torch
from botorch.fit import fit_gpytorch_mll
from botorch.models.gp_regression import SingleTaskGP
from botorch.models.model_list_gp_regression import ModelListGP
from botorch.sampling.list_sampler import ListSampler
from botorch.sampling.normal import SobolQMCNormalSampler
from gpytorch.mlls.sum_marginal_log_likelihood import SumMarginalLogLikelihood

model = ModelListGP(
    *[SingleTaskGP(train_X=torch.tensor([[0.0], [1.0]]), train_Y=torch.tensor([[0.0], [1.0]])) for _ in range(2)]
)
mll = SumMarginalLogLikelihood(model.likelihood, model)
mll = fit_gpytorch_mll(mll)
sampler = ListSampler(*[SobolQMCNormalSampler(sample_shape=torch.Size([1])) for _ in range(2)])

# Works:
model.fantasize(
    torch.tensor([[0.5]]),
    sampler=sampler,
    observation_noise=torch.tensor([[0.2, 0.2]]),
    evaluation_mask=torch.tensor([[1.0, 1.0]], dtype=torch.bool),
)

# Now also works:
model.fantasize(
    torch.tensor([[0.5]]),
    sampler=sampler,
    observation_noise=torch.tensor([[0.2, 0.2]]),
)

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 6, 2025
Copy link
Contributor

@saitcakmak saitcakmak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix!

@facebook-github-bot
Copy link
Contributor

@saitcakmak has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.99%. Comparing base (a43bd4d) to head (95a90f1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2735   +/-   ##
=======================================
  Coverage   99.99%   99.99%           
=======================================
  Files         203      203           
  Lines       18673    18675    +2     
=======================================
+ Hits        18672    18674    +2     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ModelListGP can't fantisize samples with observation_noise unless masked
3 participants