-
Notifications
You must be signed in to change notification settings - Fork 561
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
Fix bug in preconditioned KISS-GP / Hadamard Multitask GPs #2090
Conversation
Previously in PyTorch, calling on a int/long matrix was a no-op. At some point in the PyTorch releases, this line started throwing an error (since only floating point operations can have gradients). Our implementation of pivoted cholesky previously called `matrix_arg.requires_grad_(True)` on all LazyTensor/LinearOperator arguments, without first checking whether `matrix_arg` was a floating point dtype. KISS-GP makes use of InterpolatedLazyTensor (to become InterpolatedLinearOperator), which has integer matrices (the index matrices for interpolation). This therefore produced an error message when it was used in conjunction with the pivoted cholesky preconditioner. A similar bug exists for preconditioned Hadamard Multitask GPs. (The reason this bug went undetected is because our tests for KISS-GP models and multitask models all use small datasets (N < 100). Preconditioners are not used until N > 2000 or so.) [Fixes #2056]
@@ -58,8 +58,8 @@ | |||
"metadata": {}, | |||
"outputs": [], | |||
"source": [ | |||
"train_x1 = torch.rand(50)\n", | |||
"train_x2 = torch.rand(50)\n", | |||
"train_x1 = torch.rand(2000)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By how much does this increase runtime? Should we be concerned here if this is run as part of the unit tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change (plus the ones in the other two examples) add at most one second to the test suite - I just checked.
@@ -98,7 +98,11 @@ def backward(ctx, grad_output, _): | |||
|
|||
with torch.enable_grad(): | |||
# Create a new set of matrix args that we can backpropagate through | |||
matrix_args = [matrix_arg.detach().requires_grad_(True) for matrix_arg in _matrix_args] | |||
matrix_args = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say we could also catch the error so that if there are any future changes we don't have to adjust the code here. But then raising errors is unfortunately quite slow in ptorch...
Previously in PyTorch, calling on a int/long matrix was a no-op.
At some point in the PyTorch releases, this line started throwing an error (since only
floating point operations can have gradients).
Our implementation of pivoted cholesky previously called
matrix_arg.requires_grad_(True)
on all LazyTensor/LinearOperatorarguments, without first checking whether
matrix_arg
was a floatingpoint dtype.
KISS-GP makes use of InterpolatedLazyTensor (to become InterpolatedLinearOperator), which
has integer matrices (the index matrices for interpolation). This
therefore produced an error message when it was used in conjunction with
the pivoted cholesky preconditioner. A similar bug exists for
preconditioned Hadamard Multitask GPs.
(The reason this bug went undetected is because our tests for KISS-GP
models and multitask models all use small datasets (N < 100).
Preconditioners are not used until N > 2000 or so.)
[Fixes #2056]