Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
83d2d745
Unverified
Commit
83d2d745
authored
Jul 27, 2022
by
Nouamane Tazi
Committed by
GitHub
Jul 27, 2022
Browse files
fix loading from pretrained for sharded model with `torch_dtype="auto" (#18061)
parent
7996ef74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+1
-1
No files found.
src/transformers/modeling_utils.py
View file @
83d2d745
...
@@ -2073,7 +2073,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
...
@@ -2073,7 +2073,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
elif
not
is_sharded
:
elif
not
is_sharded
:
torch_dtype
=
get_state_dict_dtype
(
state_dict
)
torch_dtype
=
get_state_dict_dtype
(
state_dict
)
else
:
else
:
one_state_dict
=
load_state_dict
(
resolved_archive_file
)
one_state_dict
=
load_state_dict
(
resolved_archive_file
[
0
]
)
torch_dtype
=
get_state_dict_dtype
(
one_state_dict
)
torch_dtype
=
get_state_dict_dtype
(
one_state_dict
)
del
one_state_dict
# free CPU memory
del
one_state_dict
# free CPU memory
else
:
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment