Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions hyperactor_mesh/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fn bench_actor_scaling(c: &mut Criterion) {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -147,6 +148,7 @@ fn bench_actor_mesh_message_sizes(c: &mut Criterion) {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions hyperactor_mesh/examples/sieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ async fn main() -> Result<ExitCode> {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
})
.await?;

Expand Down
29 changes: 24 additions & 5 deletions hyperactor_mesh/src/actor_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ pub(crate) mod test_util {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -888,7 +889,8 @@ mod tests {
extent: extent! { replica = 1 },
constraints: Default::default(),
proc_name: None,
transport: default_transport()
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand All @@ -913,7 +915,8 @@ mod tests {
extent: extent!(replica = 4),
constraints: Default::default(),
proc_name: None,
transport: default_transport()
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -942,6 +945,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -980,6 +984,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1026,6 +1031,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1070,6 +1076,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1104,6 +1111,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1153,6 +1161,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1185,6 +1194,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1216,6 +1226,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1282,6 +1293,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1352,6 +1364,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1421,6 +1434,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1535,6 +1549,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Unix,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1620,6 +1635,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Unix,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -1783,7 +1799,8 @@ mod tests {
extent,
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
}))
.unwrap();
let instance = runtime.block_on(crate::v1::testing::instance());
Expand Down Expand Up @@ -1816,7 +1833,8 @@ mod tests {
extent: extent.clone(),
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
}))
.unwrap();
let instance = runtime.block_on(crate::v1::testing::instance());
Expand Down Expand Up @@ -1890,7 +1908,8 @@ mod tests {
extent,
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Local
transport: ChannelTransport::Local,
proc_allocation_mode: Default::default(),
}))
.unwrap();
let instance = runtime.block_on(crate::v1::testing::instance());
Expand Down
32 changes: 32 additions & 0 deletions hyperactor_mesh/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,27 @@ pub struct AllocConstraints {
pub match_labels: HashMap<String, String>,
}

/// Specifies how to interpret the extent dimensions for allocation.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum ProcAllocationMode {
/// Proc-level allocation: splits extent to allocate multiple processes per host.
/// Requires at least 2 dimensions (e.g., [hosts: N, gpus: M]).
/// Splits by second-to-last dimension, creating N regions with M processes each.
/// Used by MastAllocator.
ProcLevel,
/// Host-level allocation: each point in the extent is a host (no sub-host splitting).
/// For extent!(region = 2, host = 4), create 8 regions, each representing 1 host.
/// Used by MastHostAllocator.
HostLevel,
}

impl Default for ProcAllocationMode {
fn default() -> Self {
// Default to ProcLevel for backward compatibility
Self::ProcLevel
}
}

/// A specification (desired state) of an alloc.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AllocSpec {
Expand All @@ -151,6 +172,15 @@ pub struct AllocSpec {

/// The transport to use for the procs in this alloc.
pub transport: ChannelTransport,

/// Specifies how to interpret the extent dimensions for allocation.
/// Defaults to ProcLevel for backward compatibility.
#[serde(default = "default_proc_allocation_mode")]
pub proc_allocation_mode: ProcAllocationMode,
}

fn default_proc_allocation_mode() -> ProcAllocationMode {
ProcAllocationMode::ProcLevel
}

/// The core allocator trait, implemented by all allocators.
Expand Down Expand Up @@ -767,6 +797,7 @@ pub(crate) mod testing {
constraints: Default::default(),
proc_name: None,
transport: default_transport(),
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down Expand Up @@ -919,6 +950,7 @@ pub(crate) mod testing {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Unix,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions hyperactor_mesh/src/alloc/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ mod tests {
constraints: Default::default(),
proc_name: None,
transport: ChannelTransport::Unix,
proc_allocation_mode: Default::default(),
})
.await
.unwrap();
Expand Down
Loading
Loading