Skip to content

Commit f5da95b

Browse files
mivertowskiclaude
andcommitted
feat: add dynamic actor scheduling framework with scheduler warp codegen
Gap analysis item 4.1: Static actor assignment has no load balancing. Core (scheduling.rs): - SchedulingStrategy: Static, WorkStealing, RoundRobin, Priority - WorkItem (16B repr(C)) for scheduler work queue - SchedulerWarpConfig for codegen integration - 14 new tests (22 total) Runtime (LaunchOptions): - Add scheduler_config field with with_scheduler() builder CUDA codegen (ring_kernel.rs): - Scheduler warp pattern: warp 0 monitors load, rest compute - generate_scheduler_warp_code() with strategy-specific codegen - WorkStealing: neighbor scan, victim selection, steal signaling - Work sharing: overload detection, offer publication - RoundRobin/Priority: framework + placeholders for global queue - Adds LoadEntry* parameter to kernel signature when enabled - 18 new codegen tests (59 total ring_kernel tests) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 91e5143 commit f5da95b

5 files changed

Lines changed: 1084 additions & 1 deletion

File tree

crates/ringkernel-core/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ pub mod prelude {
187187
SYSTEM_MEMORY_MARGIN,
188188
};
189189
pub use crate::runtime::*;
190+
pub use crate::scheduling::{
191+
LoadEntry, LoadTable, SchedulerConfig, SchedulerWarpConfig, SchedulingStrategy, StealOp,
192+
WorkItem,
193+
};
190194
pub use crate::runtime_context::{
191195
AppInfo, BackgroundTaskStatus, CircuitGuard, ContextMetrics, DegradationGuard,
192196
HealthCycleResult, LifecycleState, MonitoringConfig, MonitoringHandles, OperationPriority,

crates/ringkernel-core/src/runtime.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ use async_trait::async_trait;
8989

9090
use crate::error::Result;
9191
use crate::message::{MessageEnvelope, RingMessage};
92+
use crate::scheduling::SchedulerConfig;
9293
use crate::telemetry::KernelMetrics;
9394
use crate::types::KernelMode;
9495

@@ -247,6 +248,14 @@ pub struct LaunchOptions {
247248
/// Enable K2K (kernel-to-kernel) messaging.
248249
/// Allocates routing table and inbox buffers on GPU.
249250
pub enable_k2k: bool,
251+
/// Dynamic scheduling configuration for persistent actor load balancing.
252+
///
253+
/// When set to a non-`Static` strategy, the codegen layer generates a
254+
/// scheduler warp pattern: warp 0 in each block handles work distribution,
255+
/// remaining warps perform computation.
256+
///
257+
/// Default: `None` (static scheduling, current behavior).
258+
pub scheduler_config: Option<SchedulerConfig>,
250259
}
251260

252261
impl Default for LaunchOptions {
@@ -261,6 +270,7 @@ impl Default for LaunchOptions {
261270
auto_activate: true,
262271
cooperative: false,
263272
enable_k2k: false,
273+
scheduler_config: None,
264274
}
265275
}
266276
}
@@ -339,6 +349,26 @@ impl LaunchOptions {
339349
self
340350
}
341351

352+
/// Configure dynamic actor scheduling for load balancing.
353+
///
354+
/// When set, the codegen layer generates a scheduler warp pattern within
355+
/// each persistent kernel block. Warp 0 handles work distribution (stealing,
356+
/// round-robin, or priority-based), while remaining warps process messages.
357+
///
358+
/// # Example
359+
///
360+
/// ```ignore
361+
/// use ringkernel_core::scheduling::SchedulerConfig;
362+
///
363+
/// let options = LaunchOptions::default()
364+
/// .with_scheduler(SchedulerConfig::work_stealing(8)
365+
/// .with_max_steal_batch(16));
366+
/// ```
367+
pub fn with_scheduler(mut self, config: SchedulerConfig) -> Self {
368+
self.scheduler_config = Some(config);
369+
self
370+
}
371+
342372
/// Set priority hint for kernel scheduling.
343373
///
344374
/// Note: This is a hint for future use - currently ignored by backends.

0 commit comments

Comments
 (0)