Skip to content

Commit

Permalink
fix mac
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengjieLi28 committed Jul 14, 2023
1 parent 26ac453 commit c5d1496
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
9 changes: 7 additions & 2 deletions python/xoscar/collective/process_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from abc import ABC, abstractmethod
from typing import Any, List, Optional

from ..utils import is_macos
from . import xoscar_pygloo as xp
from .common import (
RENDEZVOUS_MASTER_IP_ENV_KEY,
Expand Down Expand Up @@ -149,8 +150,12 @@ def __init__(
opt.isServer = rank == 0

store = xp.rendezvous.TCPStore(master_ip, opt)
attr = xp.transport.tcp.attr(ip)
dev = xp.transport.tcp.CreateDevice(attr) # type: ignore
if is_macos():
attr = xp.transport.uv.attr(ip) # type: ignore
dev = xp.transport.uv.CreateDevice(attr) # type: ignore
else:
attr = xp.transport.tcp.attr(ip)
dev = xp.transport.tcp.CreateDevice(attr) # type: ignore

Check warning on line 158 in python/xoscar/collective/process_group.py

View check run for this annotation

Codecov / codecov/patch

python/xoscar/collective/process_group.py#L157-L158

Added lines #L157 - L158 were not covered by tests
_world.store = store # type: ignore
_world.device = dev # type: ignore
else:
Expand Down
6 changes: 4 additions & 2 deletions python/xoscar/collective/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from ... import Actor, create_actor_pool, get_pool_config
from ...context import get_context
from ...utils import is_macos
from ..common import (
RANK_ADDRESS_ENV_KEY,
RENDEZVOUS_MASTER_IP_ENV_KEY,
Expand Down Expand Up @@ -158,13 +159,14 @@ async def test_collective_np(self):
await self.test_gather()
await self.test_allgather()
await self.test_scatter()
await self.test_reduce_scatter()
if not is_macos():
await self.test_reduce_scatter()
await self.test_alltoall()
await self.test_broadcast()


@pytest.mark.asyncio
async def test_init_process_group():
async def test_collective():
pool = await create_actor_pool(
"127.0.0.1",
n_process=3,
Expand Down
4 changes: 4 additions & 0 deletions python/xoscar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,7 @@ def is_windows():

def is_linux():
return sys.platform.startswith("linux")


def is_macos():
return sys.platform.startswith("darwin")

0 comments on commit c5d1496

Please sign in to comment.