Skip to content

Commit e737273

Browse files
committed
[monarch] refactor monarch/ callsites to use monarch.actor
as title Differential Revision: [D77823401](https://our.internmc.facebook.com/intern/diff/D77823401/) ghstack-source-id: 294437417 Pull Request resolved: #438
1 parent cc1674f commit e737273

File tree

11 files changed

+31
-22
lines changed

11 files changed

+31
-22
lines changed

examples/grpo_actor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
import torch
1414
import torch.nn as nn
1515
import torch.optim as optim
16-
from monarch.actor_mesh import Actor, ActorMeshRef, endpoint
1716

18-
from monarch.proc_mesh import proc_mesh
17+
from monarch.actor import Actor, ActorMeshRef, endpoint, proc_mesh
1918
from monarch.rdma import RDMABuffer
2019
from torch.distributions import Categorical, kl_divergence
2120

examples/notebooks/ping_pong.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"metadata": {},
1717
"source": [
1818
"## Hello World\n",
19-
"Actors are spawned in Process meshes via the `monarch.proc_mesh` API. For those familiar with distributed systems, it can be helpful to think of each Actor as a server with endpoints that can be called."
19+
"Actors are spawned in Process meshes via the `monarch.actor` API. For those familiar with distributed systems, it can be helpful to think of each Actor as a server with endpoints that can be called."
2020
]
2121
},
2222
{
@@ -43,8 +43,8 @@
4343
"source": [
4444
"import asyncio\n",
4545
"\n",
46-
"from monarch.proc_mesh import proc_mesh, ProcMesh\n",
47-
"from monarch.actor_mesh import Actor, endpoint, current_rank\n",
46+
"from monarch.actor import proc_mesh, ProcMesh\n",
47+
"from monarch.actor import Actor, endpoint, current_rank\n",
4848
"\n",
4949
"NUM_ACTORS=4\n",
5050
"\n",
@@ -168,8 +168,8 @@
168168
"source": [
169169
"import asyncio\n",
170170
"\n",
171-
"from monarch.proc_mesh import proc_mesh, ProcMesh\n",
172-
"from monarch.actor_mesh import Actor, endpoint, current_rank\n",
171+
"from monarch.actor import proc_mesh, ProcMesh\n",
172+
"from monarch.actor import Actor, endpoint, current_rank\n",
173173
"\n",
174174
"class ExampleActor(Actor):\n",
175175
" def __init__(self, actor_name):\n",

examples/notebooks/spmd_ddp.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"import torch.nn as nn\n",
2525
"import torch.optim as optim\n",
2626
"\n",
27-
"from monarch.proc_mesh import proc_mesh\n",
28-
"from monarch.actor_mesh import Actor, current_rank, endpoint\n",
27+
"from monarch.actor import proc_mesh\n",
28+
"from monarch.actor import Actor, current_rank, endpoint\n",
2929
"\n",
3030
"from torch.nn.parallel import DistributedDataParallel as DDP\n",
3131
"\n",

monarch_extension/src/mesh_controller.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use hyperactor::PortRef;
3030
use hyperactor::cap::CanSend;
3131
use hyperactor::mailbox::MailboxSenderError;
3232
use hyperactor_mesh::Mesh;
33-
use hyperactor_mesh::ProcMesh;
3433
use hyperactor_mesh::actor_mesh::RootActorMesh;
3534
use hyperactor_mesh::shared_cell::SharedCell;
3635
use hyperactor_mesh::shared_cell::SharedCellRef;

python/monarch/_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
import monarch_supervisor
1616
from monarch.actor._shape import NDSlice
17+
from monarch.actor import proc_mesh, ProcMesh
1718
from monarch.common.client import Client
1819
from monarch.common.device_mesh import DeviceMesh
1920
from monarch.common.invocation import DeviceException, RemoteException
2021
from monarch.controller.backend import ProcessBackend
2122
from monarch.mesh_controller import spawn_tensor_engine
22-
from monarch.proc_mesh import proc_mesh, ProcMesh
2323
from monarch.python_local_mesh import PythonLocalContext
2424
from monarch.rust_local_mesh import (
2525
local_mesh,

python/monarch/actor/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,34 @@
1212
Accumulator,
1313
Actor,
1414
ActorError,
15+
ActorMeshRef,
1516
current_actor_name,
1617
current_rank,
1718
current_size,
1819
endpoint,
1920
MonarchContext,
21+
Point,
22+
send,
2023
ValueMesh,
2124
)
2225
from monarch.actor._future import Future
23-
from monarch.actor._proc_mesh import proc_mesh, ProcMesh
26+
from monarch.actor._proc_mesh import local_proc_mesh, proc_mesh, ProcMesh
2427

2528
__all__ = [
2629
"Accumulator",
2730
"Actor",
2831
"ActorError",
32+
"ActorMeshRef",
2933
"current_actor_name",
3034
"current_rank",
3135
"current_size",
3236
"endpoint",
37+
"Future",
38+
"local_proc_mesh",
3339
"MonarchContext",
34-
"ValueMesh",
40+
"Point",
3541
"proc_mesh",
3642
"ProcMesh",
37-
"Future",
43+
"send",
44+
"ValueMesh",
3845
]

python/monarch/mesh_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
ActorId,
3535
)
3636
from monarch.actor._shape import NDSlice
37-
from monarch.actor_mesh import Port, PortTuple
37+
from monarch.actor._actor_mesh import Port, PortTuple
3838
from monarch.common import messages
3939
from monarch.common.controller_api import TController
4040
from monarch.common.invocation import Seq

python/tests/error_test_binary.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
from monarch._rust_bindings.monarch_extension.panic import panicking_function
1515

16-
from monarch.actor_mesh import Actor, endpoint, send
17-
from monarch.proc_mesh import proc_mesh
16+
from monarch.actor import Actor, endpoint, proc_mesh, send
1817

1918

2019
class ErrorActor(Actor):

python/tests/test_actor_error.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
import pytest
1212
from monarch._rust_bindings.monarch_hyperactor.proc_mesh import ProcEvent
13-
from monarch.actor_mesh import Actor, ActorError, endpoint, send
14-
from monarch.proc_mesh import local_proc_mesh, proc_mesh
13+
from monarch.actor import Actor, ActorError, endpoint, local_proc_mesh, proc_mesh
1514

1615

1716
class ExceptionActor(Actor):

python/tests/test_allocator.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@
3232
ChannelAddr,
3333
ChannelTransport,
3434
)
35+
from monarch.actor import (
36+
Actor,
37+
current_rank,
38+
current_size,
39+
endpoint,
40+
ProcMesh,
41+
ValueMesh,
42+
)
3543
from monarch.actor._allocator import (
3644
ALLOC_LABEL_PROC_MESH_NAME,
3745
RemoteAllocator,
3846
StaticRemoteAllocInitializer,
3947
TorchXRemoteAllocInitializer,
4048
)
41-
from monarch.actor_mesh import Actor, current_rank, current_size, endpoint, ValueMesh
42-
from monarch.proc_mesh import ProcMesh
4349
from monarch.tools.mesh_spec import MeshSpec, ServerSpec
4450
from monarch.tools.network import get_sockaddr
4551

0 commit comments

Comments
 (0)