-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add KernelLinearOperator, deprecate KeOpsLinearOperator #62
Conversation
@jacobrgardner @Balandat can one of you take a look at this? |
This implementation works perfectly when using one KeOps kernel, but there are a few problems when combining kernels. This is not specifically a problem with I tried to multiply two keops kernels (which make a
I was thinking could |
@m-julian there is unfortunately no way to do a symbolic element-wise multiplication of two kernels. KeOps (and LinearOperator) can keep things symbolic by using matrix multiplication based algorithms (CG/Lanczos) for solves and log determinants. Unfortunately, matrix multiplication does not distribute over element wise product. The current Lanczos solution comes out of the Product Kernel Interpolation paper (it was the best solution we could come up with). Therefore, I don't know if there's a better way to handle the product of two matrices than what we currently do in code.
This would probably be a can of worms. DenseLinearOperator assumes that the matrix is represented by a tensor. |
Regarding the product discussion: Regarding a general implementation that would be part of GPyTorch, I also do not know of a better approach than what @gpleiss pointed out. However, from a user's perspective, you, @m-julian, could of course write a custom KeOps kernel. Most likely, this would even be faster than two separate kernels, as you only need one trip from global memory to processor registers on the GPU. |
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 can't say I did check all the indexing logic in exhaustive detail, but hopefully we have some test coverage for that?
linear_operator/operators/linear_operator_representation_tree.py
Outdated
Show resolved
Hide resolved
KeOpsLinearOperator does not correctly backpropagate gradients if the covar_func closes over parameters. KernelLinearOperator corrects for this, and is set up to replace LazyEvaluatedKernelTensor in GPyTorch down the line.
Previously, only positional args were added to the LinearOperator representation, and so only positional args would receive gradients from _bilinear_derivative. This commit also adds Tensor/LinearOperator kwargs to the representation, and so kwarg Tensor/LinearOperators will also receive gradients.
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
cornellius-gp#62 introduced an inconsistency of the `linear_ops` property of `KroneckerProductLinearOperator` (by making it a `list` rather than a `tuple` in some cases). This broke some downstream usage of this that relied on this being a tuple.
"are incompatible for a Kronecker product." | ||
) | ||
|
||
if len(batch_broadcast_shape): # Otherwise all linear_ops are non-batch, and we don't need to expand |
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 introduced an inconsistency in the type of linear_ops
(a list
rather than a tuple
), which resulted in some downstream breakages in botorch. Fixed in #66.
KeOpsLinearOperator does not correctly backpropagate gradients if the covar_func closes over parameters.
KernelLinearOperator corrects for this, and is set up to replace LazyEvaluatedKernelTensor in GPyTorch down the line.
[Addresses issues in #2296]