[Hardware][TPU] Optionally import for TPU backend (#18269)
Signed-off-by: Siyuan Liu <lsiyuan@google.com> Signed-off-by: Jade Zheng <zheng.shoujian@outlook.com> Co-authored-by: Carol Zheng <cazheng@google.com> Co-authored-by: Jade Zheng <zheng.shoujian@outlook.com> Co-authored-by: Hongmin Fan <fanhongmin@google.com>
This commit is contained in:
co-authored by
Carol Zheng
Jade Zheng
Hongmin Fan
parent
3e0d435027
commit
48ac2bed5b
@@ -91,3 +91,12 @@ class TpuCommunicator(DeviceCommunicatorBase):
|
||||
def all_gather(self, input_: torch.Tensor, dim: int = -1) -> torch.Tensor:
|
||||
assert dim == -1, "TPUs only support dim=-1 for all-gather."
|
||||
return xm.all_gather(input_, dim=dim)
|
||||
|
||||
|
||||
try:
|
||||
from tpu_commons.distributed.device_communicators import (
|
||||
TpuCommunicator as TpuCommonsCommunicator)
|
||||
TpuCommunicator = TpuCommonsCommunicator # type: ignore
|
||||
except ImportError:
|
||||
logger.info("tpu_commons not found, using vLLM's TpuCommunicator")
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user