Fix loading state dict for SingleTaskVariationalGP/ApproximateGPyTorchModel (#3251)#3251
Open
esantorella wants to merge 1 commit into
Open
Fix loading state dict for SingleTaskVariationalGP/ApproximateGPyTorchModel (#3251)#3251esantorella wants to merge 1 commit into
esantorella wants to merge 1 commit into
Conversation
|
@esantorella has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98021112. |
1 task
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
2164555 to
e226558
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: Pull Request resolved: meta-pytorch#3251 **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
e226558 to
0411b48
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
0411b48 to
e16a039
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
e16a039 to
3b81636
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
3b81636 to
cdad515
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: Pull Request resolved: meta-pytorch#3251 **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
cdad515 to
41cac3f
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: Pull Request resolved: meta-pytorch#3251 **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
41cac3f to
e0a3e37
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: Pull Request resolved: meta-pytorch#3251 **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
e0a3e37 to
209c699
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3251 +/- ##
=======================================
Coverage 99.98% 99.98%
=======================================
Files 220 220
Lines 21871 21890 +19
=======================================
+ Hits 21867 21886 +19
Misses 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
209c699 to
2b5189e
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 26, 2026
…hModel (meta-pytorch#3251) Summary: Pull Request resolved: meta-pytorch#3251 **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
2b5189e to
6242791
Compare
esantorella
added a commit
to esantorella/botorch
that referenced
this pull request
Mar 27, 2026
…hModel (meta-pytorch#3251) Summary: **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
6242791 to
0ee5330
Compare
…hModel (meta-pytorch#3251) Summary: Pull Request resolved: meta-pytorch#3251 **Context**: See `https://github.com/meta-pytorch/botorch/issues/3250` . GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its `model` attribute (e.g. `model.model.train_targets`). **Changes**: - Extracted two new overridable methods on GPyTorchModel: _untransform_targets() (undo outcome transform and return raw targets) and _retransform_and_set_targets(). Note: `None` typing effectively replaces `hasattr` checks for `train_targets` - Used these methods in `load_state_dict` - Overrode both methods on ApproximateGPyTorchModel to read from / write to self.model.train_targets and self.model.train_inputs instead of self. Differential Revision: D98021112
0ee5330 to
cfe0514
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Context: See
https://github.com/meta-pytorch/botorch/issues/3250.GPyTorchModel.load_state_dict previously accessed self.train_targets and self.train_inputs unconditionally, which failed for ApproximateGPyTorchModel because its training data lives on its
modelattribute (e.g.model.model.train_targets).Changes:
Nonetyping effectively replaceshasattrchecks fortrain_targetsload_state_dictDifferential Revision: D98021112