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

[Feature Request] Sample Shape as Constructor Parameter in MCSamplerMixin and Children #2482

Open
julianStreibel opened this issue Aug 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@julianStreibel
Copy link

🚀 Feature Request

I would like to define a custom q sample shape when instantiating Q acquisition function without knowing the posterior.

Motivation

The MCSamplerMixin allows the use of the get_sampler dispatcher when the posterior is not known at instantiation time, but it defaults to using _default_sample_shape. When the posterior is known beforehand, I can construct the acquisition function with a sampler that provides a custom sample shape. I would like the ability to provide a custom sample shape even if the posterior is not known beforehand.

Pitch

Describe the solution you'd like
Add an optional sample_shape parameter to the MCSamplerMixin constructor, using the default sample shape if not provided. This sample shape can be used when lazily instantiating the sampler with the get_sampler dispatcher in the get_posterior_samples method. This sample_shape parameter can be propagated to MCAcquisitionFunction -> SampleReducingMCAcquisitionFunction -> ...

Describe alternatives you've considered

  • Overriding the get_posterior_samples method
  • Overriding the private attribute _default_sample_shape

Are you willing to open a pull request? (See CONTRIBUTING)
Yes

@julianStreibel julianStreibel added the enhancement New feature or request label Aug 23, 2024
@saitcakmak
Copy link
Contributor

Hi @julianStreibel. Thanks for opening the issue. That's a very reasonable request, though I don't like the part where we need to add a new kwarg to all MC acquisition functions. IMO, we already have too many rarely used kwargs on many acquisition functions and I'd like to clean that up. One option I was thinking of is to move these kwargs from being acquisition function inputs to a setting file, similar to how it is done in GPyTorch (link). This would let you configure the default sample shape globally without having to add it as an input to the acquisition function constructors. Here's what this could look like:

from botorch.settings import default_sample_shape
with default_sample_shape(single_objective=torch.Size([128])):
    acqf = qLogExpectedImprovement(model=model, best_f=1.0)
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants