Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4609,11 +4609,13 @@ def mark_tied_weights_as_initialized(self, loading_info):
# Note: this is never an issue in main Transformers, as we never do module-tying, only parameter-tying, and we know
# which params are supposed to be tied to which other params
if self.is_remote_code():
# Remove those that are already initialized, but appear as missing due to module tying
# Remove those that are already initialized, but appear as missing due to module tying (only if they are not known
# tied weights, i.e. we did not explicitly mark them as initialized just above)
loading_info.missing_keys = {
key
for key in loading_info.missing_keys
if not getattr(self.get_parameter_or_buffer(key), "_is_hf_initialized", False)
if key in self.all_tied_weights_keys
or not getattr(self.get_parameter_or_buffer(key), "_is_hf_initialized", False)
}

def get_parameter_or_buffer(self, target: str):
Expand Down