From 051a8acc9a5a004dbaacd7156f77846e52ce9a5f Mon Sep 17 00:00:00 2001 From: Marc Sun <57196510+SunMarc@users.noreply.github.com> Date: Fri, 30 May 2025 17:15:39 +0200 Subject: [PATCH] Align TP check (#38328) align tp check --- src/transformers/modeling_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index 2420c585fc..5e972b3423 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -2084,7 +2084,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, PushToHubMixin, PeftAdapterMi if plan := getattr(module, "_tp_plan", None): self._tp_plan.update({f"{name}.{k}": v for k, v in plan.copy().items()}) - if self._tp_plan is not None and is_torch_greater_or_equal("2.5"): + if self._tp_plan is not None and is_torch_greater_or_equal("2.5") and _torch_distributed_available: for _, v in self._tp_plan.items(): if v not in ALL_PARALLEL_STYLES: raise ValueError(