diff --git a/core/continuum-serving/src/modules/serving_daemon/budget.rs b/core/continuum-serving/src/modules/serving_daemon/budget.rs index 4a9ba44f34..a25c14787c 100644 --- a/core/continuum-serving/src/modules/serving_daemon/budget.rs +++ b/core/continuum-serving/src/modules/serving_daemon/budget.rs @@ -213,10 +213,6 @@ impl ServingDaemonModule { // anti-pattern the memory-authority arc exists to kill. Pressure sensing stays live // via the drive mode below (which still reads system available for the fraction). let available = self.system.snapshot().memory.available_bytes; - let unified = matches!( - self.system.gpu_memory_mode(), - Some(crate::gpu::monitor::MemoryMode::Unified) - ); let (measured, leases) = self.resource_daemon .replacement_budget_snapshot(SERVING_CONSUMER_ID, serving_pool_kind()); let (live, charged) = if measured > 0 { @@ -280,7 +276,7 @@ impl ServingDaemonModule { ); } } - let instant = plan_fill(live, mode.serving_fraction(), unified); + let instant = plan_fill(live, mode.serving_fraction()); // The plan budgets the sustained MINIMUM over one relaunch's duration (READY_TIMEOUT): // headroom that has not outlived a relaunch has not earned one; pressure is honoured // at once. The M5, 2026-10-18 15:27-15:28Z: the instantaneous budget read 22.9, 29.8, diff --git a/core/continuum-serving/src/modules/serving_daemon/device_budget.rs b/core/continuum-serving/src/modules/serving_daemon/device_budget.rs index a4d79e51cf..b14745bc23 100644 --- a/core/continuum-serving/src/modules/serving_daemon/device_budget.rs +++ b/core/continuum-serving/src/modules/serving_daemon/device_budget.rs @@ -26,32 +26,19 @@ pub fn seed_device_vram_prior(total_bytes: u64) { } /// The bytes the plan may fill out of the replace-myself budget `live` under a mode's -/// fraction. On UNIFIED memory the serving pool and the pressure monitor measure the -/// same bytes, so a fill to the mode's fraction can leave the box inside the Eco band: -/// measured 2026-09-19 17:56–18:20Z on the M5 (64 GB, Comfort, budget 40 GB) — 2 × 67k -/// (27 GB) became 3 × 67k (32 GB) the tick the fit allowed it, with zero slack; the -/// compressor took 6 GB of other processes' pages, "external" read 15 → 23 GB, the budget -/// fell 40 → 33, Eco entered, the plan collapsed to one lane at the floor and admission -/// followed it: five minds on one of three slots for the hour. Comfort's 20% of a 40 GB -/// budget is 8 GB — UNDER the 12 GiB Eco exit line — so a full Comfort fill is already -/// inside the band. The plan therefore never fills within [`ECO_EXIT_BYTES`] of the -/// budget on unified memory: the band the mode machinery already defines, one place, -/// where #4230's removed 15% used to sit by accident. A box small enough that Eco's own -/// fraction is the tighter bound keeps the mode alone (the band is absolute; the mode -/// scales). Discrete VRAM is a different pool from host memory: the band does not apply. -pub fn plan_fill(live: u64, fraction: f64, unified: bool) -> u64 { - use crate::capacity::power_mode::{PowerMode, ECO_EXIT_BYTES}; - let by_mode = (live as f64 * fraction) as u64; - if !unified { - return by_mode; - } - let eco_floor = (live as f64 * PowerMode::Eco.serving_fraction()) as u64; - let above_band = live.saturating_sub(ECO_EXIT_BYTES); - if above_band > eco_floor { - by_mode.min(above_band) - } else { - by_mode - } +/// fraction: the mode's fraction is the one reserve, and it scales with the machine. The +/// budget it is applied to is already the sustained minimum over one relaunch +/// (`budget_readings`), which is what keeps a wandering "available" from flipping the plan. +/// +/// A second, flat reserve sat here: the Eco exit edge (12 GiB) subtracted from every unified +/// plan after the 2026-09-19 collapse (a fill with zero slack, the compressor's response read +/// as co-consumer growth), a month before the sustained minimum fixed that flapping at its +/// source. On a 64 GB node it withheld a fifth of the machine: on the M5, 2026-10-29, with +/// ~25 GB available it left the plan 16.5 GB, three 27,904-token lanes for four residents and +/// a median 17 s per act waiting for a slot. The Eco band stays where it belongs, deciding when +/// the MODE changes; it is not a capacity reserve. +pub fn plan_fill(live: u64, fraction: f64) -> u64 { + (live as f64 * fraction) as u64 } /// The fraction a production budget may hand the plan: the operator's headroom policy, diff --git a/core/continuum-serving/src/modules/serving_daemon/tests/budget.rs b/core/continuum-serving/src/modules/serving_daemon/tests/budget.rs index c78d8c9e21..440c2768ae 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests/budget.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests/budget.rs @@ -158,67 +158,18 @@ fn pin_swap_down_credits_the_evicted_incumbents_weights() { // what this catches (2026-09-17, the M5): a steady hold pinning a boot shape of // 8 × 12,800 against a plan of 3 × 67,340 for 255 ticks. The hold yields to a // shortfall of REHOME_HOLD_OVERRIDE_PCT or more; a few-percent grow-back stays held. -// what this catches (2026-09-19 17:56–18:20Z, the M5 at 3 lanes then 1): on unified -// memory a plan filled to Comfort's fraction sat inside the Eco band, the third lane -// went in with zero slack, the compressor's response read as co-consumer growth, and -// the plan collapsed. The fill on unified memory stops ECO_EXIT_BYTES short of the -// budget: the M5's 40.3 GB budget plans 2 × 67k (27.4 GB) and never 3; Eco's own -// fraction still rules when it is tighter; a small box keeps the mode alone; discrete -// VRAM is unchanged. +// what this catches: a machine-specific constant sizing every plan. The plan fills the mode's +// fraction of the sustained budget, the same on unified and discrete memory; the M5's 2026-10-29 +// plan withheld a flat 12 GiB on top (three lanes for four residents, 17 s median slot wait). #[test] -fn a_unified_plan_never_fills_within_the_eco_band() { - use crate::inference::planning::serving_plan::ModelFootprint; - use crate::capacity::power_mode::{PowerMode, ECO_EXIT_BYTES}; - let live = 40_300_000_000u64; // the M5 at rest: available 13.4 GB + serving 26.9 GB - let comfort = PowerMode::Comfort.serving_fraction(); - let fill = plan_fill(live, comfort, true); - assert_eq!( - fill, - live - ECO_EXIT_BYTES, - "the band, not the fraction, is the ceiling on the M5" - ); - assert!(fill < (live as f64 * comfort) as u64); - assert_eq!( - plan_fill(live, comfort, false), - (live as f64 * comfort) as u64, - "discrete VRAM: the mode alone" - ); - let eco = PowerMode::Eco.serving_fraction(); - assert_eq!( - plan_fill(live, eco, true), - (live as f64 * eco) as u64, - "Eco is tighter than the band: Eco rules" - ); - let small = 20_000_000_000u64; - assert_eq!( - plan_fill(small, comfort, true), - (small as f64 * comfort) as u64, - "a small box: the band would leave less than Eco does; the mode alone" - ); - // The M5's own fit at that ceiling: two 67k lanes of the 27B, never three. - let m5 = ModelFootprint { - model_id: "qwen-27b".into(), - weights_bytes: 19_000_000_000, - kv_per_token: 32_768, - context_window: 262_144, - capability_rank: 42, - fixed_per_lane_bytes: 0, - }; - let floor = 64_052; // typical prompt 51,242 × 1.25 - assert!( - m5.window_within(fill, 2) >= floor, - "two lanes clear the floor: {}", - m5.window_within(fill, 2) - ); - assert!( - m5.window_within(fill, 3) < floor, - "three do not — the zero-slack third lane is what collapsed the box" - ); - let by_mode = (live as f64 * comfort) as u64; - assert!( - m5.window_within(by_mode, 3) >= floor, - "under the bare fraction the third lane fit, with nothing to spare" - ); +fn a_plan_fills_the_modes_fraction_and_nothing_flat() { + use crate::capacity::power_mode::PowerMode; + for live in [20_000_000_000u64, 40_300_000_000, 120_000_000_000] { + for mode in [PowerMode::Eco, PowerMode::Comfort, PowerMode::Performance] { + let expected = (live as f64 * mode.serving_fraction()) as u64; + assert_eq!(plan_fill(live, mode.serving_fraction()), expected, "{live} {mode:?}"); + } + } } // what this catches (#4230, BigMama's condition): with the plan's own reserve gone, a