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.
Description
Related to #898, this PR address the fact that we double save
nn.Modules
in both thehparams
and in thestate_dict
. This PR follows David's idea here.The main downside to this PR is a lot more code is required to implement this versus continuing to double save. The main upside is that model files will be a little smaller.
Other notes
metrics
inMPNN
is a list ofModules
so the whole list is pickled and unpickled to save and load. This is different than all the other Modules likecriterion
which are rebuilt each time a model is loaded.The default
task_weights
forcriterion
is an array, so I don't need to check if there aretask_weights
in thestate_dict
. For the other cases, the default isNone
/Identity
so in those cases, I need to check if their are corresponding parameters in thestate_dict
and if so build aModule
with zeros.While working on this PR, I found that for multicomponent message passing, if a single block is shared between two components, the weights for that block appear twice in the
state_dict
. I don't know if the weights just have two key values, or if they are truly saved twice in the model file. Not sure if this is something we should try to change.