Skip to content

: actor: port receiver monitoring is made non-optional #578

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shayne-fletcher
Copy link
Contributor

Differential Revision: D78528860

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 18, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

Rollback Plan:

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary: Pull Request resolved: pytorch-labs#578

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary: Pull Request resolved: pytorch-labs#578

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary: Pull Request resolved: pytorch-labs#578

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:
Pull Request resolved: pytorch-labs#578

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:
Pull Request resolved: pytorch-labs#578

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@shayne-fletcher shayne-fletcher force-pushed the export-D78528860 branch 2 times, most recently from 3a93f96 to 3fd2829 Compare July 18, 2025 22:29
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:
Pull Request resolved: pytorch-labs#578

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:
Pull Request resolved: pytorch-labs#578

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

@shayne-fletcher shayne-fletcher force-pushed the export-D78528860 branch 2 times, most recently from de8a1b3 to d1e3a5c Compare July 18, 2025 22:53
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 18, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 19, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 19, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@shayne-fletcher shayne-fletcher force-pushed the export-D78528860 branch 2 times, most recently from 278f95f to 3e97aaa Compare July 19, 2025 00:31
shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 19, 2025
Summary:

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

shayne-fletcher added a commit to shayne-fletcher/monarch-1 that referenced this pull request Jul 19, 2025
Summary:
Pull Request resolved: pytorch-labs#578

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
Summary:
Pull Request resolved: pytorch-labs#578

this diff moves supervision logic from python into rust, aligning with the goal of eliminating complex supervision wiring in python.

the essential change is that:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> "PortTuple[R]":
        monitor = (
            None
            if self._actor_mesh._actor_mesh is None
            else self._actor_mesh._actor_mesh.monitor()
        )
        return PortTuple.create(self._mailbox, monitor, once)
```
becomes:
```
class ActorEndpoint(...):
    def _port(self, once: bool = False) -> PortTuple[R]:
        p, r = PortTuple.create(self._mailbox, once)
        return PortTuple(p, PortReceiver(self._mailbox, self._supervise(r._receiver)))
```
`_supervise(...)` dispatches to new Rust helpers:
```python
mesh.supervise_port(...) and mesh.supervise_once_port(...)
```
which wrap the receivers with supervision logic (including selection between message arrival and supervision events), completely eliminating the need for python-side constructs like `ActorMeshMonitor`.

most of the python complexity introduced in D77434080 is removed. the only meaningful addition is `_supervise(...)`, a small overrideable hook that defaults to a no-op and cleanly delegates to rust when supervision is desired.

- the creation and wiring of the monitor stream is now fully in rust.
- the responsibility of wrapping receivers with supervision is now fully in rust.
- python no longer constructs or passes supervision monitors; rust now owns the full wiring, and python receives already-wrapped receivers with supervision behavior embedded

this is a strict improvement: lower complexity, cleaner override points and supervision is entirely managed in rust.

Differential Revision: D78528860
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78528860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants