Skip to content

Conversation

TobyBoyne
Copy link
Contributor

Currently, index kernels cannot be pickled. This PR moves an anonymous function to the module-level to allow pickling.

Current behaviour is that index kernels with a prior throw an error when pickling.

from gpytorch.kernels import IndexKernel
from gpytorch.priors import LKJPrior
import pickle

kernel = IndexKernel(2, prior=LKJPrior(2, 1))
pickle.dumps(kernel)

This throws
> AttributeError: Can't pickle local object 'IndexKernel.__init__.<locals>.<lambda>'

There isn't an open issue for this in particular, but there is a request for pickle-able kernels. (#907, #2264)

Copy link
Collaborator

@Balandat Balandat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Balandat Balandat enabled auto-merge February 28, 2024 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants