Skip to content

Commit 14199e6

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Turn off fast computations by default (#1547)
Summary: Pull Request resolved: #1547 These have been leading to many bugs in Ax and BoTorch without any clear benefit for most of our use cases. Since these are advanced features, it makes sense to require an advanced user to opt-in rather than leaving them enabled by default. Reviewed By: dme65 Differential Revision: D41829982 fbshipit-source-id: f85cc63723e09c65513f007b3d97567952efd092
1 parent 55cbaa1 commit 14199e6

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

botorch/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# This source code is licensed under the MIT license found in the
55
# LICENSE file in the root directory of this source tree.
66

7+
import gpytorch.settings as gp_settings
8+
import linear_operator.settings as linop_settings
79
from botorch import (
810
acquisition,
911
exceptions,
@@ -24,14 +26,29 @@
2426
gen_candidates_torch,
2527
get_best_candidates,
2628
)
29+
from botorch.logging import logger
2730
from botorch.utils import manual_seed
2831

29-
3032
try:
3133
from botorch.version import version as __version__
3234
except Exception: # pragma: no cover
3335
__version__ = "Unknown" # pragma: no cover
3436

37+
logger.info(
38+
"Turning off `fast_computations` in linear operator and increasing "
39+
"`max_cholesky_size` and `max_eager_kernel_size` to 4096, and "
40+
"`cholesky_max_tries` to 6. The approximate computations available in "
41+
"GPyTorch aim to speed up GP training and inference in large data "
42+
"regime but they are generally not robust enough to be used in a BO-loop. "
43+
"See gpytorch.settings & linear_operator.settings for more details."
44+
)
45+
linop_settings._fast_covar_root_decomposition._default = False
46+
linop_settings._fast_log_prob._default = False
47+
linop_settings._fast_solves._default = False
48+
linop_settings.cholesky_max_tries._global_value = 6
49+
linop_settings.max_cholesky_size._global_value = 4096
50+
gp_settings.max_eager_kernel_size._global_value = 4096
51+
3552

3653
__all__ = [
3754
"acquisition",

test/test_settings.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import warnings
88

9+
import gpytorch.settings as gp_settings
10+
import linear_operator.settings as linop_settings
911
from botorch import settings
1012
from botorch.exceptions import BotorchWarning
1113
from botorch.utils.testing import BotorchTestCase
@@ -46,3 +48,13 @@ def test_debug(self):
4648
with warnings.catch_warnings(record=True) as ws:
4749
warnings.warn("test", BotorchWarning)
4850
self.assertEqual(len(ws), 0)
51+
52+
53+
class TestDefaultGPyTorchLinOpSettings(BotorchTestCase):
54+
def test_default_gpytorch_linop_settings(self):
55+
self.assertTrue(linop_settings._fast_covar_root_decomposition.off())
56+
self.assertTrue(linop_settings._fast_log_prob.off())
57+
self.assertTrue(linop_settings._fast_solves.off())
58+
self.assertEqual(linop_settings.cholesky_max_tries.value(), 6)
59+
self.assertEqual(linop_settings.max_cholesky_size.value(), 4096)
60+
self.assertEqual(gp_settings.max_eager_kernel_size.value(), 4096)

0 commit comments

Comments
 (0)