Skip to content

Commit

Permalink
Disable quick init for deepspeed (huggingface#32066)
Browse files Browse the repository at this point in the history
Disable via deepspeed
  • Loading branch information
muellerzr authored and MHRDYN7 committed Jul 23, 2024
1 parent 2c8a597 commit 94dce2e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,15 @@ def check_support_param_buffer_assignment(model_to_load, state_dict, start_prefi
as when loading in empty weights) by first checking
if the model explicitly disables it, then by ensuring that the state dict keys
are a subset of the model's parameters.
Note: We fully disable this if we are using `deepspeed`
"""
if len([key for key in state_dict if key.startswith(start_prefix)]) == 0:
return False

if is_deepspeed_zero3_enabled():
return False

# Some models explicitly do not support param buffer assignment
if not getattr(model_to_load, "_supports_param_buffer_assignment", True):
logger.debug(
Expand Down

0 comments on commit 94dce2e

Please sign in to comment.