Skip to content

: actor_mesh: use commactor in cast_slices #461

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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions hyperactor_mesh/src/actor_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use hyperactor::RemoteMessage;
use hyperactor::Unbind;
use hyperactor::WorldId;
use hyperactor::actor::RemoteActor;
use hyperactor::attrs::Attrs;
use hyperactor::cap;
use hyperactor::mailbox::MailboxSenderError;
use hyperactor::mailbox::PortReceiver;
Expand All @@ -49,7 +48,6 @@ use crate::comm::multicast::CastMessage;
use crate::comm::multicast::CastMessageEnvelope;
use crate::comm::multicast::DestinationPort;
use crate::comm::multicast::Uslice;
use crate::comm::multicast::set_cast_info_on_headers;
use crate::metrics;
use crate::proc_mesh::ProcMesh;
use crate::reference::ActorMeshId;
Expand Down Expand Up @@ -237,32 +235,26 @@ impl<'a, A: RemoteActor> RootActorMesh<'a, A> {
/// Until the selection logic is more powerful, we need a way to
/// replicate the send patterns that the worker actor mesh actually does.
#[allow(clippy::result_large_err)] // TODO: Consider reducing the size of `CastError`.
pub fn cast_slices<M: RemoteMessage + Clone>(
&self,
sel: Vec<Slice>,
message: M,
) -> Result<(), CastError>
pub fn cast_slices<M>(&self, sel: Vec<Slice>, message: M) -> Result<(), CastError>
where
M: Castable + Clone,
A: RemoteHandles<M> + RemoteHandles<IndexedErasedUnbound<M>>,
{
let _ = metrics::ACTOR_MESH_CAST_DURATION.start(hyperactor::kv_pairs!(
"message_type" => M::typename(),
"message_variant" => message.arm().unwrap_or_default(),
));
for ref slice in sel {
for rank in slice.iter() {
let mut headers = Attrs::new();
set_cast_info_on_headers(
&mut headers,
rank,
self.shape().clone(),
self.proc_mesh.client().actor_id().clone(),
);
self.ranks[rank]
.send_with_headers(self.proc_mesh.client(), headers, message.clone())
.map_err(|err| CastError::MailboxSenderError(rank, err))?;
}
}

let slices: &[&Slice] = &sel.iter().collect::<Vec<_>>();
let selection = self
.proc_mesh
.shape()
.slice()
.reify_views(slices)
.expect("invalid slices");

self.cast(selection, message)?;

Ok(())
}

Expand Down Expand Up @@ -528,6 +520,7 @@ mod tests {
use $crate::sel_from_shape;
use $crate::sel;
use $crate::proc_mesh::SharedSpawnable;
use $crate::comm::multicast::set_cast_info_on_headers;
use std::collections::VecDeque;
use hyperactor::data::Serialized;

Expand Down
Loading