Skip to content

Commit 65635eb

Browse files
committed
fix the logic to check whether SP is actually enabled
1 parent 997eae8 commit 65635eb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/accelerate/accelerator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,11 @@ def _get_tensor_address(p):
16361636
return args
16371637

16381638
def _prepare_cp(self, *args):
1639-
if self.parallelism_config.sp_backend == "deepspeed":
1640-
# deepspeed handles cp in a different way, configured in _prepare_deepspeed
1639+
# Skip CP setup if SP (Sequence Parallelism) is actually enabled (sp_size > 1)
1640+
# CP and SP are mutually exclusive - they're different approaches for handling long sequences:
1641+
# - CP uses Ring Attention (FSDP2-based)
1642+
# - SP uses ALST/Ulysses (DeepSpeed-based)
1643+
if self.parallelism_config.sp_enabled:
16411644
return args
16421645

16431646
from torch.distributed.tensor.experimental import context_parallel

0 commit comments

Comments
 (0)