Initial commit
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
//! Configuration for elastic training.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Scaling policy for elastic training
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ScalingPolicy {
|
||||
/// Manual scaling only
|
||||
Manual,
|
||||
/// Scale based on resource availability
|
||||
ResourceBased,
|
||||
/// Scale based on training throughput
|
||||
ThroughputBased,
|
||||
/// Scale based on cost efficiency
|
||||
CostBased,
|
||||
}
|
||||
|
||||
/// Worker state in elastic cluster
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum WorkerState {
|
||||
/// Worker is initializing
|
||||
Initializing,
|
||||
/// Worker is active and training
|
||||
Active,
|
||||
/// Worker is draining (preparing to leave)
|
||||
Draining,
|
||||
/// Worker is paused
|
||||
Paused,
|
||||
/// Worker has failed
|
||||
Failed,
|
||||
/// Worker is being removed
|
||||
Removing,
|
||||
}
|
||||
|
||||
/// Configuration for elastic training
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ElasticConfig {
|
||||
/// Minimum number of workers
|
||||
pub min_workers: usize,
|
||||
/// Maximum number of workers
|
||||
pub max_workers: usize,
|
||||
/// Initial number of workers
|
||||
pub initial_workers: usize,
|
||||
/// Scaling policy
|
||||
pub scaling_policy: ScalingPolicy,
|
||||
/// Heartbeat interval (ms)
|
||||
pub heartbeat_interval_ms: u64,
|
||||
/// Failure detection timeout (ms)
|
||||
pub failure_timeout_ms: u64,
|
||||
/// Enable automatic checkpointing before scale events
|
||||
pub checkpoint_on_scale: bool,
|
||||
/// Enable automatic state redistribution
|
||||
pub redistribute_state: bool,
|
||||
/// Cooldown period between scale events (ms)
|
||||
pub scale_cooldown_ms: u64,
|
||||
/// Maximum pending scale operations
|
||||
pub max_pending_scales: usize,
|
||||
}
|
||||
|
||||
impl Default for ElasticConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
min_workers: 1,
|
||||
max_workers: 64,
|
||||
initial_workers: 4,
|
||||
scaling_policy: ScalingPolicy::Manual,
|
||||
heartbeat_interval_ms: 1000,
|
||||
failure_timeout_ms: 30000,
|
||||
checkpoint_on_scale: true,
|
||||
redistribute_state: true,
|
||||
scale_cooldown_ms: 60000,
|
||||
max_pending_scales: 4,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user