Skip to content

Commit cb7b9da

Browse files
laurahanuelusenji
authored andcommitted
only load state dict when the checkpoint is not None (huggingface#16673)
1 parent 70ca98a commit cb7b9da

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/transformers/modeling_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
17921792

17931793
# load pt weights early so that we know which dtype to init the model under
17941794
if from_pt:
1795-
if not is_sharded:
1795+
if not is_sharded and state_dict is None:
17961796
# Time to load the checkpoint
17971797
state_dict = load_state_dict(resolved_archive_file)
17981798
# set dtype to instantiate the model under:

0 commit comments

Comments
 (0)