-
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
Raise error if "initialize" method is called in eval mode. #1610
base: main
Are you sure you want to change the base?
Conversation
FWIW I'd prefer to reset caches if parameters change/on |
I agree that this might be a nicer solution. However, AFAIK the caches are all stored in the GP class and not the kernel class, and I don't know if the kernel classes contain any references to the GP class that contains them, and therefore wouldn't be able to delete the cache unless the code structure was refactored. |
@jpchen @AustinT when you call initialize to load parameters for the kernel, are you typically calling initialize on the kernel (e.g., In the latter case we could clear the caches by overriding initialize on ExactGP instead of the solution here, and then override it on Kernel to throw an error suggesting people initialize on the model if they want to do it in eval mode. |
Personally I've usually just used the setters (i.e. |
@AustinT @jacobrgardner @jpchen one possible (but maybe overly-complicated) solution would be to give each module a UUID that is updated every time some sort of state is changed (e.g. calling "initialize", going into training mode, etc.). We could then update the Of course, this would be a major undertaking. Not sure if there are simpler solutions, but we could probably use an overhaul of our caching code anyways. |
I call |
I like the motivation for this. Would a simpler solution simply be to give each child module a reference to its parent module (perhaps in the parent's |
I think changing Then again, I don't think any solution we come up with will catch the case of like, someone modifying the parameters of a NN feature extractor on a |
I never even thought about the case of changing the underlying parameters of a Another solution I can think of is to have a setting on the base GP class to always recompute cached values (aka not use caching)? Users could then turn this on or off depending on what they are doing. Perhaps even having caches off by default might be a good choice for people who are playing around with hyperparameters in jupyter notebooks... The |
This PR is in response to #1556, wherein updating kernel hyperparameters while in eval mode leads to incorrect predictions because the cached values in
model.prediction_strategy
are not updated. As suggested by @jacobrgardner a simple way to avoid this is to throw an error if the parameters are updated in eval mode. I've implemented this by adding a small check inModule.initialize
.Pros of this implementation:
self.initialize
)Cons of this implementation:
.training
attribute to be different between submodules (for example if the user manually sets them). It is unclear if this can be avoided since the kernel modules don't seem to contain a reference to the GP model that contains them.raw_*
tensors directly (although maybe this isn't a bad thing)