Skip to content

[Bug]: BoTorch changes GPyTorch's default settings on import #2934

@slishak-PX

Description

@slishak-PX

What happened?

I think this issue is already well-known, but I noticed there isn't an issue that actually tracks it.

When BoTorch is imported, it globally changes the behaviour of GPyTorch:
https://github.com/pytorch/botorch/blob/07ce3763b3d4336ad6ba9ba02195a53d607fb59b/botorch/__init__.py#L36-L49

In a production context, this makes it complicated to adopt BoTorch as an additional dependency of a package which already depends on GPyTorch, as it will change GPyTorch behaviour in pre-existing parts of the code.

As a workaround, we use a context manager that sets the BoTorch-specific default settings when actually using BoTorch models, but otherwise they remain as they are in GPyTorch. Maybe something like this could be implemented inside BoTorch (when fitting a model or optimizing an acquisition function).

Please provide a minimal, reproducible example of the unexpected behavior.

N/A

Please paste any relevant traceback/logs produced by the example provided.

BoTorch Version

0.14.0

Python Version

No response

Operating System

No response

(Optional) Describe any potential fixes you've considered to the issue outlined above.

No response

Pull Request

Yes

Code of Conduct

  • I agree to follow BoTorch's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions