Skip to content

Commit dd8c6aa

Browse files
committed
[hyperactor] mesh: combine CAST_RANK and CAST_SHAPE into a single header
... as these must always be set together; thus their usage is correct by construction. Differential Revision: [D78119117](https://our.internmc.facebook.com/intern/diff/D78119117/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D78119117/)! ghstack-source-id: 295481934 Pull Request resolved: #493
1 parent 3ae532b commit dd8c6aa

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

hyperactor_mesh/src/comm/multicast.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,20 @@ pub(crate) struct ForwardMessage {
179179
}
180180

181181
declare_attrs! {
182-
/// Used inside headers for cast messages to store
183-
/// the rank of the receiver.
184-
attr CAST_RANK: usize;
185-
/// Used inside headers to store the shape of the
186-
/// actor mesh that a message was cast to.
187-
attr CAST_SHAPE: Shape;
182+
/// Casting metadata comprising:
183+
/// 1) the rank of the receiver in the mesh,
184+
/// 2) the shape of the mesh on which the message is being cast.
185+
///
186+
/// The mesh here is the root mesh -- i.e., the shape is the extents
187+
/// of the mesh on which the actors were spawned.
188+
attr CAST_INFO: (usize, Shape);
189+
188190
/// Used inside headers to store the originating sender of a cast.
189191
pub attr CAST_ORIGINATING_SENDER: ActorId;
190192
}
191193

192194
pub fn set_cast_info_on_headers(headers: &mut Attrs, rank: usize, shape: Shape, sender: ActorId) {
193-
headers.set(CAST_RANK, rank);
194-
headers.set(CAST_SHAPE, shape);
195+
headers.set(CAST_INFO, (rank, shape));
195196
headers.set(CAST_ORIGINATING_SENDER, sender);
196197
}
197198

@@ -206,10 +207,9 @@ pub trait CastInfo {
206207
impl<A: Actor> CastInfo for Context<'_, A> {
207208
fn cast_info(&self) -> (usize, Shape) {
208209
let headers = self.headers();
209-
match (headers.get(CAST_RANK), headers.get(CAST_SHAPE)) {
210-
(Some(rank), Some(shape)) => (*rank, shape.clone()),
211-
(None, None) => (0, Shape::unity()),
212-
_ => panic!("Expected either both rank and shape or neither"),
210+
match headers.get(CAST_INFO) {
211+
Some((rank, shape)) => (*rank, shape.clone()),
212+
None => (0, Shape::unity()),
213213
}
214214
}
215215
}

0 commit comments

Comments
 (0)