-
Notifications
You must be signed in to change notification settings - Fork 121
Move supervision monitor to controller actor #2157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dulinriley
wants to merge
1
commit into
meta-pytorch:main
Choose a base branch
from
dulinriley:export-D87491033
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@dulinriley has exported this pull request. If you are a Meta employee, you can view the originating Diff in D87491033. |
dulinriley
added a commit
to dulinriley/monarch
that referenced
this pull request
Dec 16, 2025
Summary: Part of: meta-pytorch#2027 Before this change, the actor_states_monitor tokio task was only running on PyActorMesh, and only monitored PythonActors. Plus it only forwarded the SupervisionFailureMessage to other PythonActors. This means that rust-based actors have none of this error propagation working. This change moves the monitor task into the ActorMeshController, which will allow every actor, regardless of type, to monitor the mesh it owns for failures. Each Ref will subscribe to messages from the controller to alert it to changes in state. This will also scale better, as instead of each Mesh and Ref object having a monitor, there is only one per mesh globally. So there should be fewer messages going around. This also gives more implementation flexibility because the details are inside the controller, and users only need the `Subscribe` message. The subscribers are guaranteed to also get a None message, which means that the owner is still alive, and the actors have not changed their state. This can be used to detect cases where the controller is unreachable. To do the forwarding, we require the spawning context of ProcMesh::spawn to have an impl Handler<SupervisionFailureMessage>. This message represents when an actor on a mesh your actor (or client) owns fails. PythonActor uses this message to call its `__supervise__` callback, and rust actors have no default implementation. The TestRootClient and GlobalRootClient both get implementations that just panic. In the future we may want something like `unhandled_fault_hook` for Rust actors. The new method is `next_supervision_event`, a future that resolves if an event occurs. This can be awaited simultaneously via tokio::select with a reply from a casted message to re-create the Python behavior. Differential Revision: D87491033
9d943a4 to
14e5bf9
Compare
dulinriley
added a commit
to dulinriley/monarch
that referenced
this pull request
Dec 16, 2025
Summary: Part of: meta-pytorch#2027 Before this change, the actor_states_monitor tokio task was only running on PyActorMesh, and only monitored PythonActors. Plus it only forwarded the SupervisionFailureMessage to other PythonActors. This means that rust-based actors have none of this error propagation working. This change moves the monitor task into the ActorMeshController, which will allow every actor, regardless of type, to monitor the mesh it owns for failures. Each Ref will subscribe to messages from the controller to alert it to changes in state. This will also scale better, as instead of each Mesh and Ref object having a monitor, there is only one per mesh globally. So there should be fewer messages going around. This also gives more implementation flexibility because the details are inside the controller, and users only need the `Subscribe` message. The subscribers are guaranteed to also get a None message, which means that the owner is still alive, and the actors have not changed their state. This can be used to detect cases where the controller is unreachable. To do the forwarding, we require the spawning context of ProcMesh::spawn to have an impl Handler<SupervisionFailureMessage>. This message represents when an actor on a mesh your actor (or client) owns fails. PythonActor uses this message to call its `__supervise__` callback, and rust actors have no default implementation. The TestRootClient and GlobalRootClient both get implementations that just panic. In the future we may want something like `unhandled_fault_hook` for Rust actors. The new method is `next_supervision_event`, a future that resolves if an event occurs. This can be awaited simultaneously via tokio::select with a reply from a casted message to re-create the Python behavior. Differential Revision: D87491033
0d754d1 to
6056818
Compare
dulinriley
added a commit
to dulinriley/monarch
that referenced
this pull request
Dec 17, 2025
Summary: Part of: meta-pytorch#2027 Before this change, the actor_states_monitor tokio task was only running on PyActorMesh, and only monitored PythonActors. Plus it only forwarded the SupervisionFailureMessage to other PythonActors. This means that rust-based actors have none of this error propagation working. This change moves the monitor task into the ActorMeshController, which will allow every actor, regardless of type, to monitor the mesh it owns for failures. Each Ref will subscribe to messages from the controller to alert it to changes in state. This will also scale better, as instead of each Mesh and Ref object having a monitor, there is only one per mesh globally. So there should be fewer messages going around. This also gives more implementation flexibility because the details are inside the controller, and users only need the `Subscribe` message. The subscribers are guaranteed to also get a None message, which means that the owner is still alive, and the actors have not changed their state. This can be used to detect cases where the controller is unreachable. To do the forwarding, we require the spawning context of ProcMesh::spawn to have an impl Handler<SupervisionFailureMessage>. This message represents when an actor on a mesh your actor (or client) owns fails. PythonActor uses this message to call its `__supervise__` callback, and rust actors have no default implementation. The TestRootClient and GlobalRootClient both get implementations that just panic. In the future we may want something like `unhandled_fault_hook` for Rust actors. The new method is `next_supervision_event`, a future that resolves if an event occurs. This can be awaited simultaneously via tokio::select with a reply from a casted message to re-create the Python behavior. Differential Revision: D87491033
Summary: Part of: meta-pytorch#2027 Before this change, the actor_states_monitor tokio task was only running on PyActorMesh, and only monitored PythonActors. Plus it only forwarded the SupervisionFailureMessage to other PythonActors. This means that rust-based actors have none of this error propagation working. This change moves the monitor task into the ActorMeshController, which will allow every actor, regardless of type, to monitor the mesh it owns for failures. Each Ref will subscribe to messages from the controller to alert it to changes in state. This will also scale better, as instead of each Mesh and Ref object having a monitor, there is only one per mesh globally. So there should be fewer messages going around. The tokio task became an actor self-message, which has better tracking of failures and guarantees, plus no need for async locks on health state. This also gives more implementation flexibility because the details are inside the controller, and users only need the `Subscribe` message. The subscribers are guaranteed to also get a None message, which means that the owner is still alive, and the actors have not changed their state. This can be used to detect cases where the controller is unreachable. To do the forwarding, we require the spawning context of ProcMesh::spawn to have an impl Handler<SupervisionFailureMessage>. This message represents when an actor on a mesh your actor (or client) owns fails. PythonActor uses this message to call its `__supervise__` callback, and rust actors have no default implementation. The TestRootClient and GlobalRootClient both get implementations that just panic. In the future we may want something like `unhandled_fault_hook` for Rust actors. The new method is `next_supervision_event`, a future that resolves if an event occurs. This can be awaited simultaneously via tokio::select with a reply from a casted message to re-create the Python behavior. Differential Revision: D87491033
6056818 to
e92fabb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Part of: #2027
Before this change, the actor_states_monitor tokio task was only running on PyActorMesh, and
only monitored PythonActors. Plus it only forwarded the SupervisionFailureMessage to other
PythonActors. This means that rust-based actors have none of this error propagation working.
This change moves the monitor task into the ActorMeshController, which will allow every actor,
regardless of type, to monitor the mesh it owns for failures. Each Ref will subscribe to messages
from the controller to alert it to changes in state. This will also scale better, as instead of each
Mesh and Ref object having a monitor, there is only one per mesh globally. So there should be
fewer messages going around.
This also gives more implementation flexibility because the details are inside the controller,
and users only need the
Subscribemessage.The subscribers are guaranteed to also get a None message, which means that the owner
is still alive, and the actors have not changed their state. This can be used to detect cases
where the controller is unreachable.
To do the forwarding, we require the spawning context of ProcMesh::spawn to
have an impl Handler.
This message represents when an actor on a mesh your actor (or client) owns fails.
PythonActor uses this message to call its
__supervise__callback, and rust actors haveno default implementation. The TestRootClient and GlobalRootClient both get implementations
that just panic. In the future we may want something like
unhandled_fault_hookfor Rustactors.
The new method is
next_supervision_event, a future that resolves if an event occurs. Thiscan be awaited simultaneously via tokio::select with a reply from a casted message to re-create
the Python behavior.
Differential Revision: D87491033