fix break for ckpt without _tp_plan (#39658)

* fix break for ckpt without _tp_plan

* Update src/transformers/modeling_utils.py

* Update src/transformers/modeling_utils.py

---------

Co-authored-by: wangzhengtao <wangzhengtao@msh.team>
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
This commit is contained in:
bigmoyan
2025-07-26 02:03:48 +08:00
committed by GitHub
parent c06d4cd6ce
commit 5da6ad2731

View File

@@ -5991,8 +5991,9 @@ def caching_allocator_warmup(model: PreTrainedModel, expanded_device_map: dict,
if not accelerator_device_map: if not accelerator_device_map:
return return
tp_plan = getattr(model, "_tp_plan", []) or []
tp_plan_regex = ( tp_plan_regex = (
re.compile("|".join([re.escape(plan) for plan in model._tp_plan])) re.compile("|".join([re.escape(plan) for plan in tp_plan]))
if _torch_distributed_available and torch.distributed.is_initialized() if _torch_distributed_available and torch.distributed.is_initialized()
else None else None
) )