Skip to content

Commit b14850c

Browse files
mariusaefacebook-github-bot
authored andcommitted
mesh: key streams off of sender only (#397)
Summary: Pull Request resolved: #397 Each stream was previously associated with `(sender, <shape of mesh>)`, the shape being a stand-in for the mesh itself. In practice, each proc is reachable through exactly one mesh, so this is unnecessary. This change simplifies this to just the sender. In the future, we'll likely want to support multiple sessions per sender (e.g., for persistent meshes), but that is a straightforward addition we can make as needed. ghstack-source-id: 293881496 exported-using-ghexport Reviewed By: shayne-fletcher, vidhyav Differential Revision: D77609169 fbshipit-source-id: 4babc95eba0d4123f9308b43b5bf37a9dfab2747
1 parent f4d90d3 commit b14850c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

hyperactor_mesh/src/comm.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ struct ReceiveState {
8383
pub struct CommActor {
8484
/// Each world will use its own seq num from this caster.
8585
send_seq: HashMap<Slice, usize>,
86-
/// Each world/caster uses its own stream.
87-
recv_state: HashMap<(Slice, ActorId), ReceiveState>,
86+
/// Each sender is a unique stream.
87+
recv_state: HashMap<ActorId, ReceiveState>,
8888

8989
/// The comm actor's mode.
9090
mode: CommActorMode,
@@ -340,13 +340,12 @@ impl Handler<ForwardMessage> for CommActor {
340340

341341
// Resolve/dedup routing frames.
342342
let rank = self.mode.self_rank(this.self_id());
343-
let slice = dests[0].slice.as_ref().clone();
344343
let (deliver_here, next_steps) =
345344
ndslice::selection::routing::resolve_routing(rank, dests, &mut |_| {
346345
panic!("Choice encountered in CommActor routing")
347346
})?;
348347

349-
let recv_state = self.recv_state.entry((slice, sender.clone())).or_default();
348+
let recv_state = self.recv_state.entry(sender.clone()).or_default();
350349
match recv_state.seq.cmp(&last_seq) {
351350
// We got the expected next message to deliver to this host.
352351
Ordering::Equal => {

ndslice/src/selection/routing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ impl RoutingFrame {
421421
}
422422

423423
use rand::Rng;
424-
let mut rng = rand::thread_rng();
424+
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
425425
let i = rng.gen_range(0..size);
426426
let mut coord = self.here.clone();
427427
coord[self.dim] = i;

0 commit comments

Comments
 (0)