torchmonarch-nightly 2025.9.3__cp312-cp312-manylinux2014_x86_64.whl → 2025.9.4__cp312-cp312-manylinux2014_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
monarch/_rust_bindings.so CHANGED
Binary file
@@ -529,14 +529,38 @@ def as_endpoint(
529
529
 
530
530
 
531
531
  class Accumulator(Generic[P, R, A]):
532
+ """
533
+ Accumulate the result of a broadcast invocation of an endpoint
534
+ across a sliced mesh.
535
+
536
+ Usage:
537
+ >>> counter = Accumulator(Actor.increment, 0, lambda x, y: x + y)
538
+ """
539
+
532
540
  def __init__(
533
541
  self, endpoint: Endpoint[P, R], identity: A, combine: Callable[[A, R], A]
534
542
  ) -> None:
543
+ """
544
+ Args:
545
+ endpoint: Endpoint to accumulate the result of.
546
+ identity: Initial value of the accumulated value before the first combine invocation.
547
+ combine: Lambda invoked for combining the result of the endpoint with the accumulated value.
548
+ """
535
549
  self._endpoint: Endpoint[P, R] = endpoint
536
550
  self._identity: A = identity
537
551
  self._combine: Callable[[A, R], A] = combine
538
552
 
539
553
  def accumulate(self, *args: P.args, **kwargs: P.kwargs) -> "Future[A]":
554
+ """
555
+ Accumulate the result of the endpoint invocation.
556
+
557
+ Args:
558
+ args: Arguments to pass to the endpoint.
559
+ kwargs: Keyword arguments to pass to the endpoint.
560
+
561
+ Returns:
562
+ Future that resolves to the accumulated value.
563
+ """
540
564
  gen: Generator[Future[R], None, None] = self._endpoint.stream(*args, **kwargs)
541
565
 
542
566
  async def impl() -> A:
@@ -550,7 +574,7 @@ class Accumulator(Generic[P, R, A]):
550
574
 
551
575
  class ValueMesh(MeshTrait, Generic[R]):
552
576
  """
553
- Container of return values, indexed by rank.
577
+ A mesh that holds the result of an endpoint invocation.
554
578
  """
555
579
 
556
580
  def __init__(self, shape: Shape, values: List[R]) -> None:
@@ -561,6 +585,18 @@ class ValueMesh(MeshTrait, Generic[R]):
561
585
  return ValueMesh(shape, self._values)
562
586
 
563
587
  def item(self, **kwargs) -> R:
588
+ """
589
+ Get the value at the given coordinates.
590
+
591
+ Args:
592
+ kwargs: Coordinates to get the value at.
593
+
594
+ Returns:
595
+ Value at the given coordinate.
596
+
597
+ Raises:
598
+ KeyError: If invalid coordinates are provided.
599
+ """
564
600
  coordinates = [kwargs.pop(label) for label in self._labels]
565
601
  if kwargs:
566
602
  raise KeyError(f"item has extra dimensions: {list(kwargs.keys())}")
@@ -568,6 +604,12 @@ class ValueMesh(MeshTrait, Generic[R]):
568
604
  return self._values[self._ndslice.nditem(coordinates)]
569
605
 
570
606
  def items(self) -> Iterable[Tuple[Point, R]]:
607
+ """
608
+ Generator that returns values for the provided coordinates.
609
+
610
+ Returns:
611
+ Values at all coordinates.
612
+ """
571
613
  extent = self._shape.extent
572
614
  for i, rank in enumerate(self._shape.ranks()):
573
615
  yield Point(i, extent), self._values[rank]
@@ -596,14 +638,27 @@ def send(
596
638
  selection: Selection = "all",
597
639
  ) -> None:
598
640
  """
599
- Fire-and-forget broadcast invocation of the endpoint across all actors in the mesh.
641
+ Fire-and-forget broadcast invocation of the endpoint across a given selection of the mesh.
642
+
643
+ This sends the message to all actors but does not wait for any result. Use the port provided to
644
+ send the response back to the caller.
600
645
 
601
- This sends the message to all actors but does not wait for any result.
646
+ Args:
647
+ endpoint: Endpoint to invoke.
648
+ args: Arguments to pass to the endpoint.
649
+ kwargs: Keyword arguments to pass to the endpoint.
650
+ port: Handle to send the response to.
651
+ selection: Selection query representing a subset of the mesh.
602
652
  """
603
653
  endpoint._send(args, kwargs, port, selection)
604
654
 
605
655
 
606
656
  class Port(Generic[R]):
657
+ """
658
+ Handle used to send reliable in-order messages through a channel to
659
+ a PortReceiver.
660
+ """
661
+
607
662
  def __init__(
608
663
  self,
609
664
  port_ref: PortRef | OncePortRef,
@@ -615,6 +670,13 @@ class Port(Generic[R]):
615
670
  self._rank = rank
616
671
 
617
672
  def send(self, obj: R) -> None:
673
+ """
674
+ Fire-and-forget send R-typed objects in order
675
+ through a channel to its corresponding PortReceiver.
676
+
677
+ Args:
678
+ obj: R-typed object to send.
679
+ """
618
680
  self._port_ref.send(
619
681
  self._mailbox,
620
682
  PythonMessage(PythonMessageKind.Result(self._rank), _pickle(obj)),
@@ -656,8 +718,17 @@ T = TypeVar("T")
656
718
  # not part of the Endpoint API because they way it accepts arguments
657
719
  # and handles concerns is different.
658
720
  class Channel(Generic[R]):
721
+ """
722
+ An advanced low level API for a communication channel used for message passing
723
+ between actors.
724
+
725
+ Provides static methods to create communication channels with port pairs
726
+ for sending and receiving messages of type R.
727
+ """
728
+
659
729
  @staticmethod
660
730
  def open(once: bool = False) -> Tuple["Port[R]", "PortReceiver[R]"]:
731
+ """ """
661
732
  mailbox = context().actor_instance._mailbox
662
733
  handle, receiver = mailbox.open_once_port() if once else mailbox.open_port()
663
734
  port_ref = handle.bind()
@@ -673,6 +744,14 @@ class Channel(Generic[R]):
673
744
 
674
745
 
675
746
  class PortReceiver(Generic[R]):
747
+ """
748
+ Receiver for messages sent through a communication channel.
749
+
750
+ Handles receiving R-typed objects sent from a corresponding Port.
751
+ Asynchronously message reception with optional supervision
752
+ monitoring for error handling.
753
+ """
754
+
676
755
  def __init__(
677
756
  self,
678
757
  mailbox: Mailbox,
@@ -956,6 +1035,15 @@ class Actor(MeshTrait, DeprecatedNotAFuture):
956
1035
 
957
1036
 
958
1037
  class ActorMesh(MeshTrait, Generic[T], DeprecatedNotAFuture):
1038
+ """
1039
+ A group of actor instances of the same class.
1040
+
1041
+ Represents a collection of T-typed actor instances spawned at most once per process
1042
+ that can be communicated with collectively or individually. Provides
1043
+ methods for spawning actors, managing their lifecycle, and creating
1044
+ endpoints for method invocation across the mesh.
1045
+ """
1046
+
959
1047
  def __init__(
960
1048
  self,
961
1049
  Class: Type[T],
Binary file
@@ -9,7 +9,8 @@ import getpass
9
9
  from typing import Optional
10
10
 
11
11
  from monarch.tools import mesh_spec
12
- from monarch.tools.config import UnnamedAppDef
12
+
13
+ from monarch.tools.config import NOT_SET
13
14
  from monarch.tools.mesh_spec import mesh_spec_from_str
14
15
  from torchx import specs
15
16
 
@@ -19,6 +20,7 @@ _USER: str = getpass.getuser()
19
20
 
20
21
  DEFAULT_NAME: str = f"monarch-{_USER}"
21
22
 
23
+
22
24
  __version__ = "latest" # TODO get version from monarch.__version_
23
25
 
24
26
 
@@ -28,7 +30,7 @@ def host_mesh(
28
30
  env: Optional[dict[str, str]] = None,
29
31
  port: int = mesh_spec.DEFAULT_REMOTE_ALLOCATOR_PORT,
30
32
  program: str = "monarch_bootstrap", # installed with monarch wheel (as console script)
31
- ) -> UnnamedAppDef:
33
+ ) -> specs.AppDef:
32
34
  """
33
35
  Args:
34
36
  name: the name of the monarch server job
@@ -39,7 +41,7 @@ def host_mesh(
39
41
  program: path to the binary that the remote process allocator spawns on an allocation request
40
42
  """
41
43
 
42
- appdef = UnnamedAppDef()
44
+ appdef = specs.AppDef(name=NOT_SET)
43
45
 
44
46
  for mesh in [mesh_spec_from_str(mesh) for mesh in meshes]:
45
47
  mesh_role = specs.Role(
@@ -7,26 +7,22 @@
7
7
  # pyre-strict
8
8
  import warnings
9
9
  from dataclasses import dataclass, field
10
- from typing import Any, Dict, List, TYPE_CHECKING
10
+ from typing import Any
11
11
 
12
12
  from monarch.tools.config.workspace import Workspace
13
13
 
14
- # Defer the import of Role to avoid requiring torchx at import time
15
- if TYPE_CHECKING:
16
- from torchx.specs import Role
17
-
14
+ # Gracefully handle cases where torchx might not be installed
15
+ # NOTE: this can be removed once torchx.specs moves to monarch.session
16
+ try:
17
+ from torchx import specs
18
+ except ImportError:
19
+ pass
18
20
 
19
21
  NOT_SET: str = "__NOT_SET__"
20
22
 
21
23
 
22
- @dataclass
23
- class UnnamedAppDef:
24
- """
25
- A TorchX AppDef without a name.
26
- """
27
-
28
- roles: List["Role"] = field(default_factory=list)
29
- metadata: Dict[str, str] = field(default_factory=dict)
24
+ def _empty_appdef() -> "specs.AppDef":
25
+ return specs.AppDef(name=NOT_SET)
30
26
 
31
27
 
32
28
  @dataclass
@@ -39,7 +35,7 @@ class Config:
39
35
  scheduler_args: dict[str, Any] = field(default_factory=dict)
40
36
  workspace: Workspace = field(default_factory=Workspace.null)
41
37
  dryrun: bool = False
42
- appdef: UnnamedAppDef = field(default_factory=UnnamedAppDef)
38
+ appdef: "specs.AppDef" = field(default_factory=_empty_appdef)
43
39
 
44
40
  def __post_init__(self) -> None:
45
41
  # workspace used to be Optional[str]
@@ -12,7 +12,7 @@ import warnings
12
12
  from typing import Callable
13
13
 
14
14
  from monarch.tools.components import hyperactor
15
- from monarch.tools.config import Config, UnnamedAppDef
15
+ from monarch.tools.config import Config
16
16
  from monarch.tools.config.workspace import Workspace
17
17
 
18
18
  from torchx import specs
@@ -25,7 +25,7 @@ from torchx.schedulers import (
25
25
  )
26
26
 
27
27
 
28
- def component_fn(scheduler: str) -> Callable[..., UnnamedAppDef]:
28
+ def component_fn(scheduler: str) -> Callable[..., specs.AppDef]:
29
29
  """The default TorchX component function for the scheduler"""
30
30
  return hyperactor.host_mesh
31
31
 
@@ -9,8 +9,6 @@ import string
9
9
  from dataclasses import dataclass, field
10
10
  from typing import Any, Optional
11
11
 
12
- from monarch.tools.config import UnnamedAppDef
13
-
14
12
  from monarch.tools.network import get_sockaddr
15
13
  from torchx import specs
16
14
  from torchx.specs.api import is_terminal
@@ -72,7 +70,7 @@ def _tag(mesh_name: str, tag_template: str) -> str:
72
70
  return string.Template(tag_template).substitute(mesh_name=mesh_name)
73
71
 
74
72
 
75
- def tag_as_metadata(mesh_spec: MeshSpec, appdef: UnnamedAppDef) -> None:
73
+ def tag_as_metadata(mesh_spec: MeshSpec, appdef: specs.AppDef) -> None:
76
74
  appdef.metadata[_tag(mesh_spec.name, _TAG_HOST_TYPE)] = mesh_spec.host_type
77
75
  appdef.metadata[_tag(mesh_spec.name, _TAG_GPUS)] = str(mesh_spec.gpus)
78
76
  appdef.metadata[_tag(mesh_spec.name, _TAG_TRANSPORT)] = mesh_spec.transport
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: torchmonarch-nightly
3
- Version: 2025.9.3
3
+ Version: 2025.9.4
4
4
  Summary: Monarch: Single controller library
5
5
  Author: Meta
6
6
  Author-email: oncall+monarch@xmail.facebook.com
@@ -64,7 +64,7 @@ fut.get()
64
64
  ```
65
65
 
66
66
 
67
- The [introduction to monarch concepts](getting_started.html) provides an introduction to using these features.
67
+ The [introduction to monarch concepts](https://meta-pytorch.org/monarch/generated/examples/getting_started.html) provides an introduction to using these features.
68
68
 
69
69
  > ⚠️ **Early Development Warning** Monarch is currently in an experimental
70
70
  > stage. You should expect bugs, incomplete features, and APIs that may change
@@ -1,5 +1,5 @@
1
1
  monarch/__init__.py,sha256=mgKiyD1kxky-1pvhMlNfF4VmxWnhi-FSYZNFzkW1BEM,7052
2
- monarch/_rust_bindings.so,sha256=d4RzRGInKRFbwTNtBqowNU3-WMygmJcNqq9TUSF_zEo,61315880
2
+ monarch/_rust_bindings.so,sha256=Rrq4nwRBp2AFTzMN70XOP7VO9Kqn4NUaWh7BiIthKXA,61351272
3
3
  monarch/_testing.py,sha256=5BDMVA4hBMo780rsJ39vRmUZi6mTN8aYY7I9grJRjJ8,7841
4
4
  monarch/actor_mesh.py,sha256=VtPU9syi_vUdwDSJJ639Z4Y_EcWZUScyoj0lQ88RQPs,421
5
5
  monarch/bootstrap_main.py,sha256=39OZpNMrfvvNJf-iwuNzgslzYA_ItaRPHfXGn_V74N0,524
@@ -8,7 +8,7 @@ monarch/fetch.py,sha256=CssP25dMqyJnJAWoC41lwkMnSbvS-f2DL9PRbudJXfc,1704
8
8
  monarch/gradient_generator.py,sha256=b7PmoN_F3c5hQglfHeW_v5htYnePKvJGkzZN-tpHR4A,6396
9
9
  monarch/memory.py,sha256=ol86dBhFAJqg78iF25-BuK0wuwj1onR8FIioZ_B0gjw,1377
10
10
  monarch/mesh_controller.py,sha256=Y_26Cnmp72TccNbWdDQhq18j7de7pSw83E_fREJX9Yo,15372
11
- monarch/monarch_controller,sha256=AA0u7qLppriOcmqPZ30oVORlRH9QEyEPqGR8oIETQ7g,32393216
11
+ monarch/monarch_controller,sha256=ncWs8HR0sQOreG4yZrbBOnQ0qb9P-aWSzQx55xzE8N4,32393264
12
12
  monarch/notebook.py,sha256=zu9MKDFKf1-rCM2TqFSRJjMBeiWuKcJSyUFLvoZRQzs,25949
13
13
  monarch/opaque_module.py,sha256=jCcg0DjbcEVXA9WNG0NhUzGteLHOJLTZEBvrIYJIAns,10436
14
14
  monarch/opaque_object.py,sha256=x1LoX6RIMGh4ux52xIfhPgoh6PhZHdkf9bMccHW3DW0,2808
@@ -25,7 +25,7 @@ monarch/tensorboard.py,sha256=MnLgH5lbqeUJauEuirEgR6L_qYl2NGdtwZOWIAuOZao,2587
25
25
  monarch/world_mesh.py,sha256=ob5dJWaC49Uw0xqClHBm8CQLvL4xKnjd4TGzk7k8NxI,980
26
26
  monarch/_src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  monarch/_src/actor/__init__.py,sha256=4iK3nzQZmEPe0HGNY70fABBenw3lCVVaaF0xddF5Fa0,235
28
- monarch/_src/actor/actor_mesh.py,sha256=Y4IaWtVwL4h8nZ2qpOEIs3sqI2uCpVwYQZUCCHUSO80,37707
28
+ monarch/_src/actor/actor_mesh.py,sha256=QH1ITgg9pCRg6LAmdFKhPAYiuUKN757vZUslXscUbNM,40474
29
29
  monarch/_src/actor/allocator.py,sha256=UVGhrkPQMqPQp6vUngPI361s6yCEfZ0gfz8WTtG2om4,9392
30
30
  monarch/_src/actor/bootstrap_main.py,sha256=7T7ARumcHLZ5RI-k5jej9tBil0J7-BUSVFKwAZO2tJU,2413
31
31
  monarch/_src/actor/device_utils.py,sha256=gBpl23wMjppVAEzzj8U9HyX-B7Bs2_3ftiMAkzUS4j4,577
@@ -127,13 +127,13 @@ monarch/tools/__init__.py,sha256=J8qjUOysmcMAek2KFN13mViOXZxTYc5vCrF02t3VuFU,223
127
127
  monarch/tools/cli.py,sha256=b3mKZnK-MwP7JwskTxHI0KcJXxSU6498jEb2ntVr_VM,5001
128
128
  monarch/tools/colors.py,sha256=XrBkslKoaoDeXqiTluiiuvFLYd-weKp1sjw7DYWz2RY,581
129
129
  monarch/tools/commands.py,sha256=z4vCPtn_Ypic7L4_Jd3nMJWyyE4olUPqDe4cpJsDKZ4,13873
130
- monarch/tools/mesh_spec.py,sha256=9CMiLWNrgSUF0oWoAtmUT2CweMgqi4pLI18w7-EZWxs,8032
130
+ monarch/tools/mesh_spec.py,sha256=lkKZ7RxuJKY19X6kdiU_V6IWlH1GHidynOaTbuCOsAY,7983
131
131
  monarch/tools/network.py,sha256=mN8Fx9mervxM3VdFHRn4ZXt4z7yWxZp52BTxx2tfpus,2455
132
132
  monarch/tools/utils.py,sha256=gcZyalfoBC6Y3v65h-QMngwXsn24ejXh2TH8RxlgXkA,1888
133
133
  monarch/tools/components/__init__.py,sha256=J8qjUOysmcMAek2KFN13mViOXZxTYc5vCrF02t3VuFU,223
134
- monarch/tools/components/hyperactor.py,sha256=P_5XTbCl-niCj7wua-9iDaEuLVhYohetT3nScWgA7Uc,2169
135
- monarch/tools/config/__init__.py,sha256=3VV8zWKUc-yKA-wybCIbwSvDjtIzCS4dHX9KChvxn9A,2296
136
- monarch/tools/config/defaults.py,sha256=BRWDbfUkPX1Mz982EzRsYn-DlQpQw2kLIwVV2lbhpnE,2203
134
+ monarch/tools/components/hyperactor.py,sha256=OR5JtH2UCao3ke3vMohzVbuo_L0gZ_jTw8ud82qLj3M,2175
135
+ monarch/tools/config/__init__.py,sha256=wCw2qwGJL1gFuo9Wpvnrva6NKDLyjf2Yglm6Q9UJYkI,2224
136
+ monarch/tools/config/defaults.py,sha256=twUF6eT9HjJyxEZYrz2SoROHHXi3YPUDSeAelJRLBSU,2187
137
137
  monarch/tools/config/environment.py,sha256=ikEZKATa2e_8h9pN4_3TzhIHWb4ZZfRT5XtOVoOmHjI,1628
138
138
  monarch/tools/config/workspace.py,sha256=a2YzFBTLUB_VrO3kt6dCV5TlmhCH4LyRX3JCMzu7Iv0,6049
139
139
  monarch/utils/__init__.py,sha256=9ofjBGAMZo1VGsn7ufiDlrVheMw4Ye34p-isDfveUxc,295
@@ -186,9 +186,9 @@ tests/simulator/test_profiling.py,sha256=TGYCfzTLdkpIwnOuO6KApprmrgPIRQe60KRX3wk
186
186
  tests/simulator/test_simulator.py,sha256=LO8lA0ssY-OGEBL5ipEu74f97Y765TEwfUOv-DtIptM,14568
187
187
  tests/simulator/test_task.py,sha256=ipqBDuDAysuo1xOB9S5psaFvwe6VATD43IovCTSs0t4,2327
188
188
  tests/simulator/test_worker.py,sha256=QrWWIJ3HDgDLkBPRc2mwYPlOQoXQcj1qRfc0WUfKkFY,3507
189
- torchmonarch_nightly-2025.9.3.dist-info/licenses/LICENSE,sha256=e0Eotbf_rHOYPuEUlppIbvwy4SN98CZnl_hqwvbDA4Q,1530
190
- torchmonarch_nightly-2025.9.3.dist-info/METADATA,sha256=L5a1VhSSe2RevR33LVzvECh6LjPdlCV_bWkaT1nD7Zk,6184
191
- torchmonarch_nightly-2025.9.3.dist-info/WHEEL,sha256=lduYNUEDASmtUEDemd8SmeX1qOMvvA6YKAbAo1Qbwk8,104
192
- torchmonarch_nightly-2025.9.3.dist-info/entry_points.txt,sha256=60QVSpYVzkzS4iDOiLp0fsLxVp47X3J2l3v7W-59LMo,117
193
- torchmonarch_nightly-2025.9.3.dist-info/top_level.txt,sha256=E-ZssZzyM17glpVrh-S9--qJ-w9p2EjuYOuNw9tQ4Eg,33
194
- torchmonarch_nightly-2025.9.3.dist-info/RECORD,,
189
+ torchmonarch_nightly-2025.9.4.dist-info/licenses/LICENSE,sha256=e0Eotbf_rHOYPuEUlppIbvwy4SN98CZnl_hqwvbDA4Q,1530
190
+ torchmonarch_nightly-2025.9.4.dist-info/METADATA,sha256=mRWehYrs_QENvKeR77pdQ8AO9LIPeGwd1Tarqqf05gs,6236
191
+ torchmonarch_nightly-2025.9.4.dist-info/WHEEL,sha256=lduYNUEDASmtUEDemd8SmeX1qOMvvA6YKAbAo1Qbwk8,104
192
+ torchmonarch_nightly-2025.9.4.dist-info/entry_points.txt,sha256=60QVSpYVzkzS4iDOiLp0fsLxVp47X3J2l3v7W-59LMo,117
193
+ torchmonarch_nightly-2025.9.4.dist-info/top_level.txt,sha256=E-ZssZzyM17glpVrh-S9--qJ-w9p2EjuYOuNw9tQ4Eg,33
194
+ torchmonarch_nightly-2025.9.4.dist-info/RECORD,,