From 82d0a47a9c86b2092b7b56657f034e477d5a38a8 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Fri, 3 Oct 2025 11:01:47 +0530 Subject: [PATCH 1/2] up --- src/diffusers/hooks/context_parallel.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/diffusers/hooks/context_parallel.py b/src/diffusers/hooks/context_parallel.py index 83406d4969b7..2557b0dcf156 100644 --- a/src/diffusers/hooks/context_parallel.py +++ b/src/diffusers/hooks/context_parallel.py @@ -17,14 +17,17 @@ from typing import Dict, List, Type, Union import torch -import torch.distributed._functional_collectives as funcol - -from ..models._modeling_parallel import ( - ContextParallelConfig, - ContextParallelInput, - ContextParallelModelPlan, - ContextParallelOutput, -) + + +if torch.distributed.is_available(): + import torch.distributed._functional_collectives as funcol + + from ..models._modeling_parallel import ( + ContextParallelConfig, + ContextParallelInput, + ContextParallelModelPlan, + ContextParallelOutput, + ) from ..utils import get_logger from ..utils.torch_utils import unwrap_module from .hooks import HookRegistry, ModelHook From 5cf2e12effb0e10cc009a0bd8431dbf023fdd416 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Tue, 7 Oct 2025 18:57:44 +0530 Subject: [PATCH 2/2] unguard. --- src/diffusers/hooks/context_parallel.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diffusers/hooks/context_parallel.py b/src/diffusers/hooks/context_parallel.py index 2557b0dcf156..915fe453b90b 100644 --- a/src/diffusers/hooks/context_parallel.py +++ b/src/diffusers/hooks/context_parallel.py @@ -22,12 +22,12 @@ if torch.distributed.is_available(): import torch.distributed._functional_collectives as funcol - from ..models._modeling_parallel import ( - ContextParallelConfig, - ContextParallelInput, - ContextParallelModelPlan, - ContextParallelOutput, - ) +from ..models._modeling_parallel import ( + ContextParallelConfig, + ContextParallelInput, + ContextParallelModelPlan, + ContextParallelOutput, +) from ..utils import get_logger from ..utils.torch_utils import unwrap_module from .hooks import HookRegistry, ModelHook