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

Migrate trace_mode to linear_operators and disable conditional control flow #2163

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gpytorch/kernels/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ def covar_dist(
x1 = x1.transpose(-1, -2).unsqueeze(-1)
x2 = x2.transpose(-1, -2).unsqueeze(-1)

x1_eq_x2 = torch.equal(x1, x2)
if settings.trace_mode.on():
x1_eq_x2 = False
else:
x1_eq_x2 = torch.equal(x1, x2)

# torch scripts expect tensors
postprocess = torch.tensor(postprocess)
Expand Down
19 changes: 1 addition & 18 deletions gpytorch/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
preconditioner_tolerance,
skip_logdet_forward,
terminate_cg_by_size,
trace_mode,
tridiagonal_jitter,
use_toeplitz,
verbose_linalg,
Expand Down Expand Up @@ -367,24 +368,6 @@ class skip_posterior_variances(_feature_flag):
_default = False


class trace_mode(_feature_flag):
"""
If set to True, we will generally try to avoid calling our built in PyTorch functions, because these cannot
be run through torch.jit.trace.

Note that this will sometimes involve explicitly evaluating lazy tensors and various other slowdowns and
inefficiencies. As a result, you really shouldn't use this feature context unless you are calling torch.jit.trace
on a GPyTorch model.

Our hope is that this flag will not be necessary long term, once https://github.com/pytorch/pytorch/issues/22329
is fixed.

(Default: False)
"""

_default = False


class variational_cholesky_jitter(_dtype_value_context):
"""
The jitter value used for Cholesky factorizations in variational models.
Expand Down