use super::*;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StrategyRejection {
NotAllowed,
NotSelected,
NonDivisible {
field: WorkloadField,
value: usize,
degree: usize,
},
MemoryExceeded {
rank: usize,
required: usize,
limit: usize,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RejectedStrategy {
pub(super) strategy: ParallelStrategyKind,
pub(super) reason: StrategyRejection,
}
impl RejectedStrategy {
#[must_use]
pub const fn strategy(&self) -> ParallelStrategyKind {
self.strategy
}
#[must_use]
pub const fn reason(&self) -> &StrategyRejection {
&self.reason
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StrategyCandidate {
pub(super) strategy: ParallelStrategyKind,
pub(super) dtype: DTypeId,
pub(super) shards: Vec<ShardEvidence>,
pub(super) collectives: Vec<CommunicationEvidence>,
pub(super) per_rank_peak_memory: [usize; 2],
pub(super) memory_limits: [usize; 2],
pub(super) communication_bytes: usize,
pub(super) estimated_step_cost: u128,
pub(super) topology_fingerprint: u64,
pub(super) link: LinkClass,
pub(super) transport: String,
pub(super) schedule: Option<PipelineSchedule>,
}
impl StrategyCandidate {
#[must_use]
pub const fn strategy(&self) -> ParallelStrategyKind {
self.strategy
}
#[must_use]
pub const fn dtype(&self) -> DTypeId {
self.dtype
}
#[must_use]
pub fn shards(&self) -> &[ShardEvidence] {
&self.shards
}
#[must_use]
pub fn collectives(&self) -> &[CommunicationEvidence] {
&self.collectives
}
#[must_use]
pub const fn per_rank_peak_memory(&self) -> [usize; 2] {
self.per_rank_peak_memory
}
#[must_use]
pub const fn memory_limits(&self) -> [usize; 2] {
self.memory_limits
}
#[must_use]
pub const fn communication_bytes(&self) -> usize {
self.communication_bytes
}
#[must_use]
pub const fn estimated_step_cost(&self) -> u128 {
self.estimated_step_cost
}
#[must_use]
pub const fn topology_fingerprint(&self) -> u64 {
self.topology_fingerprint
}
#[must_use]
pub const fn link(&self) -> LinkClass {
self.link
}
#[must_use]
pub fn transport(&self) -> &str {
&self.transport
}
pub const fn schedule(&self) -> Option<PipelineSchedule> {
self.schedule
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HybridPlanReport {
pub(super) objective: PlanObjective,
pub(super) chosen: StrategyCandidate,
pub(super) feasible: Vec<StrategyCandidate>,
pub(super) pareto_frontier: Vec<ParallelStrategyKind>,
pub(super) rejected: Vec<RejectedStrategy>,
}
impl HybridPlanReport {
#[must_use]
pub const fn objective(&self) -> PlanObjective {
self.objective
}
#[must_use]
pub const fn chosen(&self) -> &StrategyCandidate {
&self.chosen
}
#[must_use]
pub fn feasible_candidates(&self) -> &[StrategyCandidate] {
&self.feasible
}
#[must_use]
pub fn pareto_frontier(&self) -> &[ParallelStrategyKind] {
&self.pareto_frontier
}
#[must_use]
pub fn rejected(&self) -> &[RejectedStrategy] {
&self.rejected
}
}