Skip to content

Commit 7465767

Browse files
suofacebook-github-bot
authored andcommitted
monarch.actor submodule (#437)
Summary: Pull Request resolved: #437 This is the proposed `monarch.actor` submodule. The public API is just a flat namespace, determined by `monarch/actor/__init__.py`. *Everything else* is a private detail, signified by lots of underscores in filenames. That's a little unforunate, but I think draws some good boundaries, and keeps the API simple to the user. Some principles that should guide us moving forward: - **Every symbol has at most two locations**: a private location (which should be exactly the same as its location in the source tree), and optionally a public location in the user-facing API. - We discourage end-users from depending on private locations via underscores, per python convention. ghstack-source-id: 294760596 exported-using-ghexport Reviewed By: mariusae Differential Revision: D77709116 fbshipit-source-id: ca9a0190ac28cdead452859396bc7d1d9596c880
1 parent 41d1dbb commit 7465767

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1409
-1276
lines changed

monarch_extension/src/mesh_controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl History {
511511
.getattr("RemoteException")
512512
.unwrap();
513513
let pickle = py
514-
.import("monarch.actor_mesh")
514+
.import("monarch._src.actor.actor_mesh")
515515
.unwrap()
516516
.getattr("_pickle")
517517
.unwrap();

monarch_tensor_worker/src/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ impl StreamActor {
990990
})
991991
.and_then(|result| -> Result<PythonMessage, WorkerError> {
992992
let pickle = py
993-
.import("monarch.actor_mesh")
993+
.import("monarch._src.actor.actor_mesh")
994994
.unwrap()
995995
.getattr("_pickle")
996996
.unwrap();

python/monarch/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
if TYPE_CHECKING:
3131
from monarch import timer
32-
from monarch.allocator import LocalAllocator, ProcessAllocator
32+
from monarch._src.actor.allocator import LocalAllocator, ProcessAllocator
33+
from monarch._src.actor.shape import NDSlice, Shape
3334
from monarch.common._coalescing import coalescing
3435

3536
from monarch.common.device_mesh import (
@@ -50,11 +51,9 @@
5051
from monarch.common.pipe import create_pipe, Pipe, remote_generator
5152
from monarch.common.remote import remote
5253
from monarch.common.selection import Selection
53-
from monarch.common.shape import NDSlice, Shape
5454
from monarch.common.stream import get_active_stream, Stream
5555
from monarch.common.tensor import reduce, reduce_, Tensor
5656
from monarch.fetch import fetch_shard, inspect, show
57-
from monarch.future import ActorFuture
5857
from monarch.gradient_generator import grad_function, grad_generator
5958
from monarch.notebook import mast_mesh, reserve_torchx as mast_reserve
6059
from monarch.python_local_mesh import python_local_mesh
@@ -79,8 +78,8 @@
7978
"function_resolvers": ("monarch.common.function", "resolvers"),
8079
"Future": ("monarch.common.future", "Future"),
8180
"RemoteException": ("monarch.common.invocation", "RemoteException"),
82-
"Shape": ("monarch.common.shape", "Shape"),
83-
"NDSlice": ("monarch.common.shape", "NDSlice"),
81+
"Shape": ("monarch._src.actor.shape", "Shape"),
82+
"NDSlice": ("monarch._src.actor.shape", "NDSlice"),
8483
"Selection": ("monarch.common.selection", "Selection"),
8584
"OpaqueRef": ("monarch.common.opaque_ref", "OpaqueRef"),
8685
"create_pipe": ("monarch.common.pipe", "create_pipe"),
@@ -112,9 +111,8 @@
112111
"Simulator": ("monarch.simulator.interface", "Simulator"),
113112
"world_mesh": ("monarch.world_mesh", "world_mesh"),
114113
"timer": ("monarch.timer", "timer"),
115-
"ProcessAllocator": ("monarch.allocator", "ProcessAllocator"),
116-
"LocalAllocator": ("monarch.allocator", "LocalAllocator"),
117-
"ActorFuture": ("monarch.future", "ActorFuture"),
114+
"ProcessAllocator": ("monarch._src.actor.allocator", "ProcessAllocator"),
115+
"LocalAllocator": ("monarch._src.actor.allocator", "LocalAllocator"),
118116
"builtins": ("monarch.builtins", "builtins"),
119117
}
120118

@@ -183,7 +181,6 @@ def __getattr__(name):
183181
"timer",
184182
"ProcessAllocator",
185183
"LocalAllocator",
186-
"ActorFuture",
187184
"builtins",
188185
]
189186
assert sorted(__all__) == sorted(_public_api)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# True iff the rust extension was built with the tensor engine feature.
8+
def has_tensor_engine() -> bool: ...

python/monarch/_rust_bindings/monarch_hyperactor/alloc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class RemoteAllocatorBase:
7373
def __new__(
7474
cls,
7575
world_id: str,
76-
initializer: "monarch.allocator.RemoteAllocInitializer", # pyre-ignore[11] defined in monarch/python/monarch/allocator.py
76+
initializer: "monarch._src.actor.allocator.RemoteAllocInitializer", # pyre-ignore[11]
7777
heartbeat_interval: timedelta = timedelta(seconds=5),
7878
) -> Self:
7979
"""

python/monarch/_src/__init__.py

Whitespace-only changes.

python/monarch/_src/actor/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
"""
8+
Monarch Actor API
9+
"""

0 commit comments

Comments
 (0)