botorch icon indicating copy to clipboard operation
botorch copied to clipboard

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

Open julianStreibel opened this issue 1 year ago • 1 comments

🚀 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 avatar Aug 23 '24 09:08 julianStreibel