[Bugfix] Fix 'ModuleNotFoundError: No module named 'intel_extension_for_pytorch'' for --tensor-parallel-size more than 1 (#12546)

This commit is contained in:
Akash kaothalkar 2025-02-05 12:41:02 +05:30 committed by GitHub
parent c53dc466b1
commit 022bcc701a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -329,9 +329,17 @@ class GroupCoordinator:
return input_
if input_.is_cpu:
import intel_extension_for_pytorch as ipex
ipex.distributed.all_reduce(input_, group=self.device_group)
return input_
try:
import intel_extension_for_pytorch as ipex
ipex.distributed.all_reduce(input_, group=self.device_group)
return input_
except ImportError:
"""
Intel IPEX not found. Falling back to PyTorch native
all_reduce for CPU
"""
torch.distributed.all_reduce(input_, group=self.device_group)
return input_
if self.tpu_communicator is not None and \
not self.tpu_communicator.disabled: