Skip to content

Commit

Permalink
add strict arg to load_checkpoint_and_dispatch (#2641)
Browse files Browse the repository at this point in the history
  • Loading branch information
SunMarc authored Apr 10, 2024
1 parent b8c8583 commit 6c09584
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/accelerate/big_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ def load_checkpoint_and_dispatch(
skip_keys: Optional[Union[str, List[str]]] = None,
preload_module_classes: Optional[List[str]] = None,
force_hooks: bool = False,
strict: bool = False,
):
"""
Loads a (potentially sharded) checkpoint inside a model, potentially sending weights to a given device as they are
Expand Down Expand Up @@ -554,6 +555,9 @@ def load_checkpoint_and_dispatch(
force_hooks (`bool`, *optional*, defaults to `False`):
Whether or not to force device hooks to be attached to the model even if all layers are dispatched to a
single device.
strict (`bool`, *optional*, defaults to `False`):
Whether to strictly enforce that the keys in the checkpoint state_dict match the keys of the model's
state_dict.
Example:
Expand Down Expand Up @@ -608,6 +612,7 @@ def load_checkpoint_and_dispatch(
dtype=dtype,
offload_state_dict=offload_state_dict,
offload_buffers=offload_buffers,
strict=strict,
)
if device_map is None:
return model
Expand Down

0 comments on commit 6c09584

Please sign in to comment.