From 5603f21dc4bb362756732204f0e3c14589c91744 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 12:21:57 -0600 Subject: [PATCH 1/5] The launch pool is the fit at the host's PHYSICAL budget, never the cold boot plan's (b4be7bc59 launched the M5 at 5 x 2,048) engine_pool sized its fit from the plan's live budget, 0 or a transient at a cold boot, and took the boot plan's bootstrap window x lanes otherwise: 2,048 for five sequences on the M5 at 18:18Z, kept for the engine's life since one launch is never relaunched to resize (rolled back to 2c0d45ca0). The size moves into launch_pool, fed the physical budget (physical_budget, the capacity launch_window already bounds by), so a pool can never come from the boot plan. Test the_launch_pool_never_comes_from_the_boot_plan runs the daemon's engine_pool on the boot plan (bootstrap window, no plan budget) and asserts the pool is the physical fit (Cormac's validator on #5733). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/modules/serving_daemon/launch.rs | 53 +++++++++++++------ .../serving_daemon/tests/one_launch.rs | 21 ++++++++ 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/core/continuum-serving/src/modules/serving_daemon/launch.rs b/core/continuum-serving/src/modules/serving_daemon/launch.rs index 37c3877320..2cc918c657 100644 --- a/core/continuum-serving/src/modules/serving_daemon/launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/launch.rs @@ -21,23 +21,20 @@ impl ServingDaemonModule { /// /// The launch decides only the pool's size; no mind's window comes from it. Each mind's /// window is her grant from her measured requirement (`grants.rs`), and under `--kv-unified` - /// any one sequence may grow into the whole pool. The pool is the most memory the plan's own - /// arithmetic proves fits: its window x its lanes, or its fit at the sequences (a window - /// within the budget for each), whichever is larger. The sequences are every seated mind, - /// the minds leased in at the last plan, and the scratch traffic, so seating never relaunches. - /// On the M5 (plan 2 x 128,768) that is 257,536 for 5; on the IntelMac (plan 2 x 32,768, - /// fit 9 x 32,768) 294,912 for 9, what it serves healthy today. Dividing the pool by the - /// sequences as each mind's window gave the M5 5 x 10,803 (b03d7c5bc) and would have given - /// the IntelMac 7,281 against 13-30k acts (Joel, 2026-11-03: "System accommodates it doesn't - /// do stupid division"). - fn engine_pool(&self, model: &crate::model_registry::types::Model, served_ctx: u32, lanes: u32) -> (u32, u32) { + /// any one sequence may grow into the whole pool. The sequences are every seated mind, the + /// minds leased in at the last plan, and the scratch traffic, so seating never relaunches. + /// The size is [`launch_pool`] at the host's PHYSICAL budget, never the plan's live one. + pub(super) fn engine_pool(&self, model: &crate::model_registry::types::Model, served_ctx: u32, lanes: u32) -> (u32, u32) { let leased_in = LAST_LEASED_IN_PEAK.load(Ordering::Relaxed); let sequences = self.seated().saturating_add(1).saturating_add(leased_in).max(lanes).max(1); - let budget = self.plan_budget_bytes.load(Ordering::Relaxed); - let plan_pool = u64::from(served_ctx) * u64::from(lanes); - let fit_pool = footprint_for(model) - .map_or(0, |fp| u64::from(fp.window_within(budget, sequences).min(model.context_window)) * u64::from(sequences)); // map_or: no footprint proves no fit beyond the plan's own pool - let pool = plan_pool.max(fit_pool); + let pool = launch_pool( + footprint_for(model).as_ref(), + self.physical_budget().usable_bytes, + served_ctx, + lanes, + sequences, + model.context_window, + ); // `-c` is the CLI's `slots x per-slot`: the pool carried in that shape, not anyone's window. let per_slot = u32::try_from(pool / u64::from(sequences)).unwrap_or(u32::MAX); // unwrap_or: a pool over u32 x sequences is no real engine; the CLI caps it (per_slot, sequences) @@ -704,3 +701,29 @@ impl ServingDaemonModule { })) } } + +/// The pool an engine launches with: the most memory the host's measured capacity proves fits. +/// That is the fit at `sequences` (a window within `budget_bytes` for each, capped at the trained +/// window) or the plan's own window x its lanes, whichever is larger. +/// +/// `budget_bytes` is the PHYSICAL budget (`physical_budget`, the capacity `launch_window` bounds by +/// too), never the plan's live one. The engine launches once and is never relaunched to resize, so +/// a pool sized at a transient is kept for the engine's life: b4be7bc59 launched the M5 at +/// 5 x 2,048 from the cold boot plan, whose window was the bootstrap 2,048 and whose live budget +/// fit nothing at five sequences (2026-11-03 18:18Z, rolled back; Cormac on #5733). On the M5 +/// (plan 2 x 128,768) the result is 257,536 for 5; on the IntelMac (plan 2 x 32,768, fit +/// 9 x 32,768) 294,912 for 9, its healthy geometry. +pub(super) fn launch_pool( + footprint: Option<&crate::inference::planning::serving_plan::ModelFootprint>, + budget_bytes: u64, + plan_window: u32, + lanes: u32, + sequences: u32, + trained_window: u32, +) -> u64 { + let plan_pool = u64::from(plan_window) * u64::from(lanes); + let fit_pool = footprint.map_or(0, |fp| { + u64::from(fp.window_within(budget_bytes, sequences).min(trained_window)) * u64::from(sequences) + }); // map_or: no footprint proves no fit beyond the plan's own pool + plan_pool.max(fit_pool) +} diff --git a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs index b212ddd61b..841f207f5c 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs @@ -112,3 +112,24 @@ fn model_swap_on_a_ready_lane_needs_a_sustained_streak() { ModelChangeGate::NotAChange ); } + +// what this catches (b4be7bc59 on the M5, 2026-11-03 18:18Z, rolled back): a launch pool sized +// from the cold boot plan. Its window was the bootstrap 2,048 and the plan's live budget fit +// nothing at five sequences, so the engine launched at 5 x 2,048, and one launch is never +// relaunched to resize. On the boot plan the pool is never smaller than the fit at the host's +// PHYSICAL budget, and never smaller than the plan's own window x lanes (Cormac on #5733). +#[test] +fn the_launch_pool_never_comes_from_the_boot_plan() { + let daemon = daemon_with(Arc::new(FakeServer::healthy(Arc::new(AtomicUsize::new(0)), true))); + assert_eq!(daemon.plan_budget_bytes.load(Ordering::Relaxed), 0, "a cold boot: no plan budget yet"); + let mut model = daemon.catalog.snapshot().values().next().expect("the catalog has a model").model.clone(); + model.weights_bytes = Some(9 * GB); + let fp = crate::inference::planning::serving_plan::footprint_for(&model).expect("a footprint from the weights"); + let (per_slot, sequences) = daemon.engine_pool(&model, 2_048, 1); + let pool = u64::from(per_slot) * u64::from(sequences); + let fit = u64::from(fp.window_within(daemon.physical_budget().usable_bytes, sequences).min(model.context_window)) + * u64::from(sequences); + assert!(fit > 2_048, "the physical budget fits more than the bootstrap window: {fit}"); + assert!(pool + u64::from(sequences) > fit, "the pool is the fit at the physical budget ({fit}), not the boot plan: {pool}"); + assert!(pool >= 2_048, "never below the plan's own window x lanes"); +} From 36d7f5af75e1bd5bb5414fc1ddd728129be9c576 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 12:42:33 -0600 Subject: [PATCH 2/5] one_launch test: the M5's catalog model, footprint_for from the module's scope Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/modules/serving_daemon/tests/one_launch.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs index 841f207f5c..6664d6a5f3 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs @@ -122,9 +122,15 @@ fn model_swap_on_a_ready_lane_needs_a_sustained_streak() { fn the_launch_pool_never_comes_from_the_boot_plan() { let daemon = daemon_with(Arc::new(FakeServer::healthy(Arc::new(AtomicUsize::new(0)), true))); assert_eq!(daemon.plan_budget_bytes.load(Ordering::Relaxed), 0, "a cold boot: no plan budget yet"); - let mut model = daemon.catalog.snapshot().values().next().expect("the catalog has a model").model.clone(); + let mut model = daemon + .catalog + .snapshot() + .get("ggml-org/Qwen3.6-35B-A3B-GGUF") + .expect("the catalog has the M5's model") + .model + .clone(); model.weights_bytes = Some(9 * GB); - let fp = crate::inference::planning::serving_plan::footprint_for(&model).expect("a footprint from the weights"); + let fp = footprint_for(&model).expect("a footprint from the weights"); let (per_slot, sequences) = daemon.engine_pool(&model, 2_048, 1); let pool = u64::from(per_slot) * u64::from(sequences); let fit = u64::from(fp.window_within(daemon.physical_budget().usable_bytes, sequences).min(model.context_window)) From 79a251440f4bf39a6fab57c3d68e10a2b9d2b4f7 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 12:44:29 -0600 Subject: [PATCH 3/5] one_launch: the boot-plan test runs in a tokio runtime (the daemon starts its resource daemon) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../src/modules/serving_daemon/tests/one_launch.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs index 6664d6a5f3..79e601b735 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs @@ -118,8 +118,8 @@ fn model_swap_on_a_ready_lane_needs_a_sustained_streak() { // nothing at five sequences, so the engine launched at 5 x 2,048, and one launch is never // relaunched to resize. On the boot plan the pool is never smaller than the fit at the host's // PHYSICAL budget, and never smaller than the plan's own window x lanes (Cormac on #5733). -#[test] -fn the_launch_pool_never_comes_from_the_boot_plan() { +#[tokio::test] +async fn the_launch_pool_never_comes_from_the_boot_plan() { let daemon = daemon_with(Arc::new(FakeServer::healthy(Arc::new(AtomicUsize::new(0)), true))); assert_eq!(daemon.plan_budget_bytes.load(Ordering::Relaxed), 0, "a cold boot: no plan budget yet"); let mut model = daemon From 5c8898f6c601dcc0fe4fdd4bb579962ff92f4f5b Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 12:48:10 -0600 Subject: [PATCH 4/5] one_launch: the boot-plan case is pinned on the pure launch_pool with fixed inputs, never the host's RAM (Cormac on #5739) The daemon-level test built the real SystemResourceMonitor, so its physical budget was the host's total RAM and 'fit > 2,048' passed or failed by machine (plan line 10, card c4d84be3). Now: the M5's model (20.69 GB, 8,317 B/token), a fixed 96 GB physical budget, the boot plan 2,048 x 1, five sequences: the pool equals the physical fit; at budget 0 (what b4be7bc59 fed it) it is the boot plan's 2,048; with no footprint it is the plan's own window x lanes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- .../serving_daemon/tests/one_launch.rs | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs index 79e601b735..16e63bae75 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests/one_launch.rs @@ -116,26 +116,21 @@ fn model_swap_on_a_ready_lane_needs_a_sustained_streak() { // what this catches (b4be7bc59 on the M5, 2026-11-03 18:18Z, rolled back): a launch pool sized // from the cold boot plan. Its window was the bootstrap 2,048 and the plan's live budget fit // nothing at five sequences, so the engine launched at 5 x 2,048, and one launch is never -// relaunched to resize. On the boot plan the pool is never smaller than the fit at the host's -// PHYSICAL budget, and never smaller than the plan's own window x lanes (Cormac on #5733). -#[tokio::test] -async fn the_launch_pool_never_comes_from_the_boot_plan() { - let daemon = daemon_with(Arc::new(FakeServer::healthy(Arc::new(AtomicUsize::new(0)), true))); - assert_eq!(daemon.plan_budget_bytes.load(Ordering::Relaxed), 0, "a cold boot: no plan budget yet"); - let mut model = daemon - .catalog - .snapshot() - .get("ggml-org/Qwen3.6-35B-A3B-GGUF") - .expect("the catalog has the M5's model") - .model - .clone(); - model.weights_bytes = Some(9 * GB); - let fp = footprint_for(&model).expect("a footprint from the weights"); - let (per_slot, sequences) = daemon.engine_pool(&model, 2_048, 1); - let pool = u64::from(per_slot) * u64::from(sequences); - let fit = u64::from(fp.window_within(daemon.physical_budget().usable_bytes, sequences).min(model.context_window)) - * u64::from(sequences); +// relaunched to resize. On the boot plan the pool is the fit at the physical budget, never the +// plan's 2,048 (Cormac on #5733). Fixed inputs, so the result never depends on the host's RAM +// (Cormac on #5739): the M5's model (20.69 GB weights, 8,317 B/token, read 11-03 12:51Z), a fixed +// 96 GB physical budget, the boot plan (2,048 x 1), five sequences. +#[test] +fn the_launch_pool_never_comes_from_the_boot_plan() { + let trained = 262_144; + let mut fp = footprint_from_parts("ggml-org/Qwen3.6-35B-A3B-GGUF", 20_690_000_000, trained, true, None) + .expect("a footprint from the weights"); + fp.kv_per_token = 8_317; + let physical = 96 * GB; + let fit = u64::from(fp.window_within(physical, 5).min(trained)) * 5; assert!(fit > 2_048, "the physical budget fits more than the bootstrap window: {fit}"); - assert!(pool + u64::from(sequences) > fit, "the pool is the fit at the physical budget ({fit}), not the boot plan: {pool}"); - assert!(pool >= 2_048, "never below the plan's own window x lanes"); + let launch_pool = super::super::launch::launch_pool; + assert_eq!(launch_pool(Some(&fp), physical, 2_048, 1, 5, trained), fit, "the pool is the physical fit, not the boot plan"); + assert_eq!(launch_pool(Some(&fp), 0, 2_048, 1, 5, trained), 2_048, "what b4be7bc59 fed it: a zero budget leaves only the boot plan"); + assert_eq!(launch_pool(None, physical, 128_768, 2, 5, trained), 257_536, "no footprint: the plan's own window x lanes"); } From 4dba6a03b5714c23bbce05e9d07cd26fe829e536 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Tue, 3 Nov 2026 12:48:22 -0600 Subject: [PATCH 5/5] engine_pool stays private: only the pure launch_pool is tested Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- core/continuum-serving/src/modules/serving_daemon/launch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/continuum-serving/src/modules/serving_daemon/launch.rs b/core/continuum-serving/src/modules/serving_daemon/launch.rs index 2cc918c657..b2fa8ace4a 100644 --- a/core/continuum-serving/src/modules/serving_daemon/launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/launch.rs @@ -24,7 +24,7 @@ impl ServingDaemonModule { /// any one sequence may grow into the whole pool. The sequences are every seated mind, the /// minds leased in at the last plan, and the scratch traffic, so seating never relaunches. /// The size is [`launch_pool`] at the host's PHYSICAL budget, never the plan's live one. - pub(super) fn engine_pool(&self, model: &crate::model_registry::types::Model, served_ctx: u32, lanes: u32) -> (u32, u32) { + fn engine_pool(&self, model: &crate::model_registry::types::Model, served_ctx: u32, lanes: u32) -> (u32, u32) { let leased_in = LAST_LEASED_IN_PEAK.load(Ordering::Relaxed); let sequences = self.seated().saturating_add(1).saturating_add(leased_in).max(lanes).max(1); let pool = launch_pool(