Skip to content

[17/n] Pass monarch tensors to actor endpoints, part 2, actor messages sent in order #539

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: gh/zdevito/40/base
Choose a base branch
from

Conversation

zdevito
Copy link
Contributor

@zdevito zdevito commented Jul 15, 2025

Stack from ghstack (oldest at bottom):

When you send a monarch.Tensor to an actor, what actually happens is that you instruct the stream managing the tensor to send the tensor to the actor.

In part 1, that stream directly told the actor what method to call, and where to send the result. The issue with that is ordering: from the perspective of the original caller it is as if we are sending a message to the actor directly. If the stream sends the message it is possible that it arrives out of order with respect to a message that goes directly to the actor (e.g. a message that contains no monarch.Tensors).

This resolves ordering issue: now the client sends a message to the actor 'CallMethodIndirect' that provides the pickled args/kwargs and method to invoke.

The local python values of the torch.Tensors still need to come from Stream actor, so CallMethodIndirect looks them up by messaging the (new) LocalStateBrokerActor which can transfer PyObjects between local actors without serialization.

Ordering is guarenteed for both tensors and actors because a message is sent to both the receiving actor and the stream actor at the same time.

Differential Revision: D78314012

…s sent in order

When you send a monarch.Tensor to an actor, what actually happens is that you instruct the stream managing the tensor to send the tensor to the actor.

In part 1, that stream directly told the actor what method to call, and where to send the result. The issue with that is ordering: from the perspective of the original caller it is as if we are sending a message to the actor directly. If the stream sends the message it is possible that it arrives out of order with respect to a message that goes directly to the actor (e.g. a message that contains no monarch.Tensors).

This resolves ordering issue: now the client sends a message to the actor 'CallMethodIndirect' that provides the pickled args/kwargs and method to invoke.

The local python values of the torch.Tensors still need to come from Stream actor, so CallMethodIndirect looks them up by messaging the (new) LocalStateBrokerActor which can transfer PyObjects between local actors without serialization.

Ordering is guarenteed for both tensors and actors because a message is sent to both the receiving actor _and_ the stream actor at the same time.

Differential Revision: [D78314012](https://our.internmc.facebook.com/intern/diff/D78314012/)

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 15, 2025
zdevito added a commit that referenced this pull request Jul 15, 2025
…s sent in order

When you send a monarch.Tensor to an actor, what actually happens is that you instruct the stream managing the tensor to send the tensor to the actor.

In part 1, that stream directly told the actor what method to call, and where to send the result. The issue with that is ordering: from the perspective of the original caller it is as if we are sending a message to the actor directly. If the stream sends the message it is possible that it arrives out of order with respect to a message that goes directly to the actor (e.g. a message that contains no monarch.Tensors).

This resolves ordering issue: now the client sends a message to the actor 'CallMethodIndirect' that provides the pickled args/kwargs and method to invoke.

The local python values of the torch.Tensors still need to come from Stream actor, so CallMethodIndirect looks them up by messaging the (new) LocalStateBrokerActor which can transfer PyObjects between local actors without serialization.

Ordering is guarenteed for both tensors and actors because a message is sent to both the receiving actor _and_ the stream actor at the same time.

Differential Revision: [D78314012](https://our.internmc.facebook.com/intern/diff/D78314012/)

ghstack-source-id: 296356330
Pull Request resolved: #539
@facebook-github-bot
Copy link
Contributor

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

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