Skip to content

Commit 283fd2a

Browse files
authored
[dist] fix communicator patch (#52)
Fix communicator patch for distributed inferencing. We should patch `GroupCoordinator` with its module, and just before initializing distributed env. So that the patch won't be shadowed by the import of `init_distributed_environment` in `worker.py` Signed-off-by: MengqingCao <cmq0113@163.com>
1 parent 3d88966 commit 283fd2a

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _read_requirements(filename: str) -> List[str]:
9595
"Topic :: Scientific/Engineering :: Artificial Intelligence",
9696
"Topic :: Scientific/Engineering :: Information Analysis",
9797
],
98-
packages=find_packages(exclude=("docs", "examples", "tests*", "patch")),
98+
packages=find_packages(exclude=("docs", "examples", "tests*")),
9999
python_requires=">=3.9",
100100
install_requires=get_requirements(),
101101
extras_require={},

vllm_ascend/patch/patch_commnicator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
# https://github.com/vllm-project/vllm/pull/11324.
2020

2121
import torch
22-
from vllm.distributed.parallel_state import GroupCoordinator
22+
import vllm
2323
from vllm.utils import resolve_obj_by_qualname
2424

2525

26-
class GroupCoordinatorPatch(GroupCoordinator):
26+
class GroupCoordinatorPatch(vllm.distributed.parallel_state.GroupCoordinator):
2727

2828
def __init__(self, *args, **kwargs):
2929
super().__init__(*args, **kwargs)
@@ -66,4 +66,4 @@ def all_gather(self, input_, dim=-1):
6666
return self.communicator.all_gather(input_, dim)
6767

6868

69-
GroupCoordinator = GroupCoordinatorPatch
69+
vllm.distributed.parallel_state.GroupCoordinator = GroupCoordinatorPatch

vllm_ascend/platform.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ def mem_get_info(cls) -> Tuple[int, int]:
9696

9797
@classmethod
9898
def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
99-
# Register ops and patch when setup.
99+
# Register ops when setup.
100100
from vllm_ascend import ops # noqa: F401
101-
from vllm_ascend import patch # noqa: F401
102101

103102
parallel_config = vllm_config.parallel_config
104103
if parallel_config.worker_cls == "auto":

vllm_ascend/worker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ def init_worker_distributed_environment(
457457
backend: str = "hccl") -> None:
458458
"""Initialize the distributed environment."""
459459
set_custom_all_reduce(not parallel_config.disable_custom_all_reduce)
460+
# register communicator patch before init dist env
461+
from vllm_ascend import patch # noqa: F401
460462

461463
init_distributed_environment(parallel_config.world_size, rank,
462464
distributed_init_method, local_rank, backend)

0 commit comments

Comments
 (0)