diff --git a/core/continuum-engine/src/inference/llama_server.rs b/core/continuum-engine/src/inference/llama_server.rs index 42c5977bb5..42d5d8d257 100644 --- a/core/continuum-engine/src/inference/llama_server.rs +++ b/core/continuum-engine/src/inference/llama_server.rs @@ -131,7 +131,7 @@ mod control; pub use control::{ EngineRetirementError, EngineRetirementReceipt, EngineRetirementStatus, EnsureOutcome, LlamaServerControl, LlamaServerError, OwnedEngineIdentity, OwnedRestoreSession, - OwnedServingTarget, ServingLifecycleCheck, + ObservedGeometry, OwnedServingTarget, ServingLifecycleCheck, }; mod prepared_launch; use prepared_launch::{unsupported_launch_environment, PreparedLocalLaunch}; diff --git a/core/continuum-engine/src/inference/llama_server/control.rs b/core/continuum-engine/src/inference/llama_server/control.rs index 09305b7876..451bca38af 100644 --- a/core/continuum-engine/src/inference/llama_server/control.rs +++ b/core/continuum-engine/src/inference/llama_server/control.rs @@ -84,12 +84,22 @@ pub struct OwnedServingTarget { /// Public diagnostic projection of explicit arguments and managed environment. /// Only the private original prepared receipt can authorize exact replay. pub invocation: crate::inference::lane_args::LaneInvocation, - pub observed_context_window: u32, - pub observed_lanes: u32, + /// The geometry the running engine reported when it came ready. + pub observed: ObservedGeometry, pub launched_host_prompt_cache_mib: u32, } +/// What a running engine reported about its context when it came ready, read off its own `/props`: +/// each sequence's limit (`n_ctx`, capped at the trained window), its sequences (`total_slots`), +/// and its whole KV pool (`context_geometry.allocated_tokens`, our fork's report). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ObservedGeometry { + pub context_window: u32, + pub lanes: u32, + pub pool_tokens: u32, +} + /// Checked at the endpoint's drained lifecycle-admission boundary. Once admitted, /// the operation may settle even if newer intent arrives; its result keeps its epoch. pub type ServingLifecycleCheck<'a> = dyn Fn() -> bool + Send + Sync + 'a; @@ -332,6 +342,13 @@ pub trait LlamaServerControl: Send + Sync { /// `n_ctx` (a loud invariant violation — never a guessed window). async fn served_context_window(&self) -> Result; + /// The tokens the engine's KV holds in all, from `/props` `context_geometry.allocated_tokens` + /// (`llama_n_ctx`): the ONE shared pool under `--kv-unified`, the sum of the slots without + /// it. Never `n_ctx` x slots: under a unified cache the fork caps each slot's `n_ctx` at the + /// model's trained window (server-context.cpp, "the slot context exceeds the training + /// context"), so `n_ctx` reads 32,768 on a 65,536 pool (IntelMac, 2026-11-03 07:32Z). + async fn served_pool_tokens(&self) -> Result; + /// The REAL number of continuous-batching slots the running server serves, /// read from its own `/props` (`total_slots`) — the LANE sibling of /// [`Self::served_context_window`], and for the same reason. diff --git a/core/continuum-engine/src/inference/llama_server/control_impl.rs b/core/continuum-engine/src/inference/llama_server/control_impl.rs index de71097277..4affbbcaba 100644 --- a/core/continuum-engine/src/inference/llama_server/control_impl.rs +++ b/core/continuum-engine/src/inference/llama_server/control_impl.rs @@ -94,6 +94,19 @@ impl LlamaServerControl for LlamaServerProcess { }) } + async fn served_pool_tokens(&self) -> Result { + let body = self.props_json().await?; + crate::inference::weight_residency::ContextGeometry::from_props(&body) + .and_then(|geometry| u32::try_from(geometry.allocated_tokens).ok()) + .ok_or_else(|| { + LlamaServerError::Unreachable( + "/props has no valid context_geometry: the engine is not our fork's (refusing \ + to guess the pool)" + .to_string(), + ) + }) + } + async fn served_engine_build(&self) -> Result, LlamaServerError> { let body = self.props_json().await?; Ok(body diff --git a/core/continuum-engine/src/inference/llama_server/late_ready.rs b/core/continuum-engine/src/inference/llama_server/late_ready.rs index bb25101158..9921e6afc9 100644 --- a/core/continuum-engine/src/inference/llama_server/late_ready.rs +++ b/core/continuum-engine/src/inference/llama_server/late_ready.rs @@ -306,7 +306,11 @@ mod tests { while !props_open.load(std::sync::atomic::Ordering::SeqCst) { tokio::time::sleep(Duration::from_millis(20)).await; } - axum::Json(serde_json::json!({ "default_generation_settings": { "n_ctx": 32768 }, "total_slots": 1 })) + axum::Json(serde_json::json!({ + "default_generation_settings": { "n_ctx": 32768 }, + "total_slots": 1, + "context_geometry": { "allocated_tokens": 32768, "max_tokens_per_sequence": 32768, "sequence_capacity": 1 } + })) } })) .route("/v1/models", axum::routing::get(|| async { diff --git a/core/continuum-engine/src/inference/llama_server/process.rs b/core/continuum-engine/src/inference/llama_server/process.rs index b3349e5a16..8e409830b6 100644 --- a/core/continuum-engine/src/inference/llama_server/process.rs +++ b/core/continuum-engine/src/inference/llama_server/process.rs @@ -347,7 +347,7 @@ impl LlamaServerProcess { return "".to_string(); }; match std::fs::read_to_string(&path) { - Ok(s) => tail_or_hang_marker(&s), + Ok(s) => tail_or_hang_marker(&path.display().to_string(), &s), // The marker is the contract (never block the error path), but a bare // "unreadable" hides WHY — permissions vs absent vs mid-rotation. Err(e) => format!(""), @@ -364,20 +364,18 @@ impl LlamaServerProcess { /// dies before llama.cpp prints its banner) vs. a genuine early-init hang (child /// still running at the deadline). A crash from bad args or a model-load fault /// prints the banner + fault FIRST, so a non-empty tail carries that directly. -/// Pure so the load-bearing empty-vs-tail decision is unit-tested without touching -/// the real `~/.continuum/logs` path ([[self-test-via-command-feedback-surface- -/// never-blind]], and #72's env-dependent-test lesson). -pub(super) fn tail_or_hang_marker(contents: &str) -> String { - let mut lines: Vec<&str> = contents.lines().rev().take(20).collect(); - lines.reverse(); - let tail = lines.join("\n"); - if tail.trim().is_empty() { - "" - .to_string() - } else { - tail +/// The report names the log (the whole output, reachable) and its last line (where a fault +/// prints); it never picks a fixed number of lines to keep. Pure so the load-bearing +/// empty-vs-fault decision is unit-tested without touching the real `~/.continuum/logs` path +/// ([[self-test-via-command-feedback-surface-never-blind]], and #72's env-dependent-test lesson). +pub(super) fn tail_or_hang_marker(log_path: &str, contents: &str) -> String { + match contents.lines().rev().find(|line| !line.trim().is_empty()) { + Some(last) => format!("{last} (full log: {log_path})"), + None => format!( + " (log: {log_path})" + ), } } @@ -407,8 +405,7 @@ impl LlamaServerProcess { invocation: &crate::inference::lane_args::LaneInvocation, prepared: Option>, engine_program: &str, - context: u32, - lanes: u32, + observed: ObservedGeometry, ) { let mut child = self.child.lock().unwrap(); // JUSTIFIED: poison means prior panic mutating the owned child. if let Some(owned) = child @@ -417,7 +414,7 @@ impl LlamaServerProcess { { let prepared = prepared.map(|original| { let mut verified = original.as_ref().clone(); - verified.expected_geometry = Some((context, lanes)); + verified.expected_geometry = Some((observed.context_window, observed.lanes)); Arc::new(verified) }); owned.verified_target = Some(OwnedServingTarget { @@ -429,8 +426,7 @@ impl LlamaServerProcess { target: target.clone(), engine_program: engine_program.to_string(), invocation: invocation.clone(), - observed_context_window: context, - observed_lanes: lanes, + observed, launched_host_prompt_cache_mib: self .launched_prompt_cache_mib .load(std::sync::atomic::Ordering::Relaxed), diff --git a/core/continuum-engine/src/inference/llama_server/ready_tail.rs b/core/continuum-engine/src/inference/llama_server/ready_tail.rs index 0895b68ca8..892adc845a 100644 --- a/core/continuum-engine/src/inference/llama_server/ready_tail.rs +++ b/core/continuum-engine/src/inference/llama_server/ready_tail.rs @@ -190,6 +190,7 @@ impl LlamaServerProcess { } let context = self.served_context_window().await?; let slots = self.served_lanes().await?; + let pool = self.served_pool_tokens().await?; if context == 0 || slots == 0 || self.child_exit_status().is_some() { return Err(LlamaServerError::Spawn( "engine readiness lacks live slot geometry".into(), @@ -231,7 +232,7 @@ impl LlamaServerProcess { transition .ready( &self.root, - &generation, + generation, crate::inference::slots::KvPageContract { model_id: target.model.id.clone(), model: gguf, @@ -253,13 +254,12 @@ impl LlamaServerProcess { } } self.record_verified_target( - &generation, + generation, target, invocation, Some(prepared.clone()), &prepared.engine_program, - context, - slots, + ObservedGeometry { context_window: context, lanes: slots, pool_tokens: pool }, ); Ok(()) } diff --git a/core/continuum-engine/src/inference/llama_server/test_fixtures.rs b/core/continuum-engine/src/inference/llama_server/test_fixtures.rs index 7ad2dec7c3..6d47689822 100644 --- a/core/continuum-engine/src/inference/llama_server/test_fixtures.rs +++ b/core/continuum-engine/src/inference/llama_server/test_fixtures.rs @@ -183,8 +183,7 @@ where &prepared.invocation, Some(prepared.clone()), &process.engine_bin().unwrap(), - 11008, - 4, + ObservedGeometry { context_window: 11008, lanes: 4, pool_tokens: 11008 * 4 }, ); drop(transition); let captured = process.owned_serving_target().unwrap(); @@ -317,8 +316,7 @@ where &prepared.invocation, Some(prepared.clone()), &process.engine_bin().unwrap(), - 11008, - 4, + ObservedGeometry { context_window: 11008, lanes: 4, pool_tokens: 11008 * 4 }, ); let transition = endpoint.transition().await; transition diff --git a/core/continuum-engine/src/inference/llama_server/tests.rs b/core/continuum-engine/src/inference/llama_server/tests.rs index 697b261206..67dc4eefdc 100644 --- a/core/continuum-engine/src/inference/llama_server/tests.rs +++ b/core/continuum-engine/src/inference/llama_server/tests.rs @@ -192,6 +192,10 @@ impl LlamaServerControl for FakeControl { // check is a no-op unless a test deliberately floors it. Ok(self.served_window) } + async fn served_pool_tokens(&self) -> Result { + // The fake's pool: its window over its lanes (at least one), as an engine reports it. + Ok(self.served_window.saturating_mul(self.served_lanes.max(1))) + } async fn served_lanes(&self) -> Result { // The slot count the fake's /props reports (configurable via // `with_served_lanes`). Defaults to 0 = "nothing to compare", so the diff --git a/core/continuum-engine/src/inference/llama_server/tests/readiness.rs b/core/continuum-engine/src/inference/llama_server/tests/readiness.rs index 7687373b0f..4b55d878d8 100644 --- a/core/continuum-engine/src/inference/llama_server/tests/readiness.rs +++ b/core/continuum-engine/src/inference/llama_server/tests/readiness.rs @@ -103,26 +103,19 @@ fn a_loading_engine_of_ours_is_not_a_failed_one() { } #[test] -fn tail_or_hang_marker_fingerprints_empty_and_tails_nonempty() { +fn tail_or_hang_marker_fingerprints_empty_and_names_the_fault_and_the_log() { + let log = "/logs/llama-server-58057.log"; assert!( - tail_or_hang_marker("").contains("OOM/jetsam"), + tail_or_hang_marker(log, "").contains("OOM/jetsam"), "an empty log is the no-output fingerprint naming the OOM-kill cause, not a silent blank" ); assert!( - tail_or_hang_marker(" \n\n \t \n").contains("OOM/jetsam"), + tail_or_hang_marker(log, " \n\n \t \n").contains("OOM/jetsam"), "whitespace-only counts as empty" ); - let log = (1..=30) - .map(|i| format!("line{i}")) - .collect::>() - .join("\n"); - let tail = tail_or_hang_marker(&log); - assert!( - tail.contains("line30") && tail.contains("line11") && !tail.contains("line10"), - "keeps the LAST 20 lines in original order, not the first: {tail}" - ); - // sanity: order preserved (line11 appears before line30) - assert!(tail.find("line11") < tail.find("line30")); + let report = tail_or_hang_marker(log, "load_model: loading\nGGML_ASSERT(n_ctx > 0) failed\n\n"); + assert!(report.starts_with("GGML_ASSERT(n_ctx > 0) failed"), "the last printed line leads: {report}"); + assert!(report.contains(log), "the whole log stays reachable by its path: {report}"); } // what this catches (M5 2026-10-25, card 9e3350bd's second site): a synthetic smoke decode diff --git a/core/continuum-engine/src/inference/llama_server/tests/retirement.rs b/core/continuum-engine/src/inference/llama_server/tests/retirement.rs index a9cf6d43a3..bc24ad6bea 100644 --- a/core/continuum-engine/src/inference/llama_server/tests/retirement.rs +++ b/core/continuum-engine/src/inference/llama_server/tests/retirement.rs @@ -185,8 +185,7 @@ async fn retiring_page_owner_requires_observed_child_exit() { &invocation, Some(prepared), &process.engine_bin().unwrap(), - 11008, - 4, + ObservedGeometry { context_window: 11008, lanes: 4, pool_tokens: 11008 * 4 }, ); drop(engine_install); let captured = process.owned_serving_target().unwrap(); @@ -272,15 +271,15 @@ async fn retiring_page_owner_requires_observed_child_exit() { true, ); let launched = invocation.clone(); - process.record_verified_target(&generation, &launch_target, &invocation, None, &process.engine_bin().unwrap(), 11008, 4); + process.record_verified_target(&generation, &launch_target, &invocation, None, &process.engine_bin().unwrap(), ObservedGeometry { context_window: 11008, lanes: 4, pool_tokens: 11008 * 4 }); // A later resolved choice cannot mutate the already verified generation. invocation.args.push("--different-future-policy".into()); let recorded = process .owned_serving_target() .expect("verified owned provenance"); assert_eq!(recorded.target.context_window, launch_target.context_window); - assert_eq!(recorded.observed_context_window, 11008); - assert_eq!(recorded.observed_lanes, 4); + assert_eq!(recorded.observed.context_window, 11008); + assert_eq!(recorded.observed.lanes, 4); assert_eq!(recorded.engine_program, process.engine_bin().unwrap()); assert_eq!(recorded.invocation, launched); let restore_admitted = std::sync::atomic::AtomicBool::new(false); @@ -305,7 +304,7 @@ async fn retiring_page_owner_requires_observed_child_exit() { let mut drifted = launch_target.clone(); // Downsize from what the engine actually serves, not the larger original // request: half of 32768 still exceeds this fixture's 11008-token lane. - drifted.context_window = recorded.observed_context_window / 2; + drifted.context_window = recorded.observed.context_window / 2; drifted.host_prompt_cache_mib = launch_target.host_prompt_cache_mib.saturating_add(1); let admissions = AtomicUsize::new(0); let admit = || { diff --git a/core/continuum-engine/src/inference/llama_server/tests/snapshot.rs b/core/continuum-engine/src/inference/llama_server/tests/snapshot.rs index ebc3adfb7a..bb440f093b 100644 --- a/core/continuum-engine/src/inference/llama_server/tests/snapshot.rs +++ b/core/continuum-engine/src/inference/llama_server/tests/snapshot.rs @@ -137,3 +137,27 @@ fn real_token_delivery_is_recorded_as_liveness_evidence() { "a decode recorded just now must read as recent, got {since}ms" ); } + +// what this catches (IntelMac, 2026-11-03 07:32Z): the share divided the slot's `n_ctx`, which +// the fork caps at the trained window under `--kv-unified` (a 65,536 pool reads 32,768), so +// each of 2 minds was published 16,384 instead of 32,768. The pool is `allocated_tokens`. +#[tokio::test] +async fn the_pool_is_the_engines_allocated_tokens_never_the_capped_slot_window() { + let app = axum::Router::new().route( + "/props", + axum::routing::get(|| async { + axum::Json(serde_json::json!({ + "default_generation_settings": {"n_ctx": 32_768}, + "total_slots": 2, + "context_geometry": {"allocated_tokens": 65_536, "max_tokens_per_sequence": 32_768, "sequence_capacity": 2} + })) + }), + ); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.expect("test: bind"); + let root = format!("http://{}", listener.local_addr().expect("test: addr")); + let server = tokio::spawn(async move { axum::serve(listener, app).await }); + let process = LlamaServerProcess::with_root(root); + assert_eq!(process.served_context_window().await.expect("test: n_ctx"), 32_768); + assert_eq!(process.served_pool_tokens().await.expect("test: pool"), 65_536); + server.abort(); +} diff --git a/core/continuum-engine/src/inference/weight_residency.rs b/core/continuum-engine/src/inference/weight_residency.rs index 6181c8f6c8..c84265bf55 100644 --- a/core/continuum-engine/src/inference/weight_residency.rs +++ b/core/continuum-engine/src/inference/weight_residency.rs @@ -167,23 +167,46 @@ impl EngineContext { } } -fn allocated_capacity(props: &serde_json::Value, slots: u32, n_ctx_per_slot: u32) -> Option { - match props.get("context_geometry") { - Some(geometry) => { - let tokens = geometry.get("allocated_tokens")?.as_u64()?; - let capacity = geometry.get("sequence_capacity")?.as_u64()?; - let window = geometry.get("max_tokens_per_sequence")?.as_u64()?; - if tokens == 0 || capacity != u64::from(slots) || window != u64::from(n_ctx_per_slot) || window > tokens { - return None; - } - Some(tokens) - } - // Older managed engines used divided caches. Only absence permits their - // legacy geometry; a present malformed receipt must never take this path. - None => Some(u64::from(slots) * u64::from(n_ctx_per_slot)), +/// The KV geometry OUR fork reports on `/props` (`context_geometry`): the contract every node's +/// engine keeps, so nothing here infers a pool from upstream fields. `allocated_tokens` is +/// `llama_n_ctx`: the ONE shared pool under `--kv-unified`, the sum of the slots without it. +/// `n_ctx` x slots is never the pool: under a unified cache the server caps each slot's `n_ctx` +/// at the trained window (a 65,536 pool read 32,768 on the IntelMac, 2026-11-03). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ContextGeometry { + pub allocated_tokens: u64, + pub max_tokens_per_sequence: u64, + pub sequence_capacity: u64, +} + +impl ContextGeometry { + /// `None` when the engine reports no geometry (not our fork) or one that does not hold + /// together: zero tokens, no sequence, or one sequence allowed more than the pool. + pub fn from_props(props: &serde_json::Value) -> Option { + let geometry = props.get("context_geometry")?; + let read = |field: &str| geometry.get(field)?.as_u64(); + let reported = Self { + allocated_tokens: read("allocated_tokens")?, + max_tokens_per_sequence: read("max_tokens_per_sequence")?, + sequence_capacity: read("sequence_capacity")?, + }; + (reported.allocated_tokens > 0 + && reported.sequence_capacity > 0 + && reported.max_tokens_per_sequence <= reported.allocated_tokens) + .then_some(reported) } } +/// The pool, when the fork's geometry agrees with the slot geometry `/props` reports beside it: +/// the same sequences, and a slot window within one sequence's limit. Within, not equal: the +/// server caps a slot's `n_ctx` at the trained window, below the per-sequence limit whenever the +/// pool is larger (IntelMac 2026-11-03: n_ctx 32,768 beside 65,536; Cormac on #5722). +fn allocated_capacity(props: &serde_json::Value, slots: u32, n_ctx_per_slot: u32) -> Option { + let geometry = ContextGeometry::from_props(props)?; + (geometry.sequence_capacity == u64::from(slots) && u64::from(n_ctx_per_slot) <= geometry.max_tokens_per_sequence) + .then_some(geometry.allocated_tokens) +} + /// The slot geometry an engine reports on `/props`: `total_slots` and each slot's `n_ctx`, both /// present, in range and nonzero. `None` otherwise. ONE parse, shared by the reading and by /// the legacy test, so "a valid props document" means one thing. @@ -232,6 +255,9 @@ mod tests { let mut with_slots = props.clone(); with_slots["total_slots"] = 2.into(); with_slots["default_generation_settings"] = serde_json::json!({"n_ctx": 2048}); + with_slots["context_geometry"] = serde_json::json!({ + "allocated_tokens": 4096, "max_tokens_per_sequence": 2048, "sequence_capacity": 2 + }); let ctx = EngineContext::from_props(&with_slots).expect("reads"); assert_eq!((ctx.context_bytes, ctx.slots, ctx.n_ctx_per_slot), (117440512, 2, 2048)); assert_eq!(ctx.beyond_weights, 117440512 + 66594944); @@ -243,10 +269,20 @@ mod tests { "allocated_tokens": 2048, "max_tokens_per_sequence": 2048, "sequence_capacity": 2 }); assert_eq!(EngineContext::from_props(&unified).expect("unified receipt").allocated_tokens, 2048); + // a pool larger than the trained window: the slot's n_ctx is capped below the + // per-sequence limit, and the reading still stands (the IntelMac's 65,536 / 32,768) + let mut capped = with_slots.clone(); + capped["default_generation_settings"] = serde_json::json!({"n_ctx": 32_768}); + capped["context_geometry"] = serde_json::json!({ + "allocated_tokens": 65_536, "max_tokens_per_sequence": 65_536, "sequence_capacity": 2 + }); + assert_eq!(EngineContext::from_props(&capped).expect("capped slot window").allocated_tokens, 65_536); for invalid in [ serde_json::Value::Null, serde_json::json!({"allocated_tokens": 0, "max_tokens_per_sequence": 2048, "sequence_capacity": 2}), serde_json::json!({"allocated_tokens": 2048, "max_tokens_per_sequence": 2048, "sequence_capacity": 3}), + // a slot window past one sequence's limit is not this engine's geometry + serde_json::json!({"allocated_tokens": 2048, "max_tokens_per_sequence": 1024, "sequence_capacity": 2}), ] { unified["context_geometry"] = invalid; assert_eq!(EngineContextReading::of(&unified), EngineContextReading::Invalid); @@ -265,10 +301,11 @@ mod tests { let mut malformed = with_slots.clone(); malformed["memory_breakdown"] = "not a list".into(); assert_eq!(EngineContextReading::of(&malformed), EngineContextReading::Invalid); - // only an engine without the field is the device delta's to measure + // an engine without our fork's geometry is no reading at all, never a legacy engine to + // guess a pool for (2026-11-03: every node runs our fork) assert_eq!( EngineContextReading::of(&serde_json::json!({"total_slots": 1, "default_generation_settings": {"n_ctx": 4096}})), - EngineContextReading::Absent + EngineContextReading::Invalid ); // and what is not a props document at all is no reading, never a legacy engine assert_eq!(EngineContextReading::of(&serde_json::Value::Null), EngineContextReading::Invalid, "null"); diff --git a/core/continuum-serving/src/modules/serving_daemon/academy_batch.rs b/core/continuum-serving/src/modules/serving_daemon/academy_batch.rs index 2ac6121f80..fd8b202de0 100644 --- a/core/continuum-serving/src/modules/serving_daemon/academy_batch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/academy_batch.rs @@ -103,10 +103,16 @@ impl ServingDaemonModule { .map(|footprint| { attribute_serving( footprint.peak_resident_bytes( - launch.observed_context_window, - launch.observed_lanes, + // Each sequence's share of the pool, so window x lanes is the pool. + sequence_share( + launch.observed.pool_tokens, + launch.observed.lanes, + launch.target.model.context_window, + ) + .0, + launch.observed.lanes, ), - launch.observed_lanes, + launch.observed.lanes, launch.launched_host_prompt_cache_mib, ) }) diff --git a/core/continuum-serving/src/modules/serving_daemon/launch.rs b/core/continuum-serving/src/modules/serving_daemon/launch.rs index 87c3ac8025..308f2731bc 100644 --- a/core/continuum-serving/src/modules/serving_daemon/launch.rs +++ b/core/continuum-serving/src/modules/serving_daemon/launch.rs @@ -326,15 +326,26 @@ impl ServingDaemonModule { } EnsureOutcome::Degraded { .. } | EnsureOutcome::Superseded => 0, }; - // ONE SHARED POOL: an engine on it names the whole pool as each sequence's window - // in `/props`; each sequence is published its share (`sequence_share`), so what the - // readers budget and charge is the pool. An engine not known to be on it publishes - // its per-slot window as served. + // ONE SHARED POOL: each sequence is published its share of the pool the engine + // reports (`served_pool_tokens`), so what the readers budget and charge is the pool. + // Never the slot's `n_ctx`: the fork caps it at the trained window, and dividing that + // again halved the IntelMac's share (2026-11-03). An unreadable pool publishes the gap + // and retries next tick. An engine not known to be on the pool publishes its slot. let (served_window, served_lanes) = match (served_window > 0, server.launched_on_shared_pool()) { - (true, Some(true)) => { - sequence_share(served_window, served_lanes, target.model.context_window) - } + (true, Some(true)) => match server.served_pool_tokens().await { + Ok(pool) => sequence_share(pool, served_lanes, target.model.context_window), + Err(e) => { + continuum_base::probe!( + target: "continuum_core::modules::serving_daemon", class = "serving.reconcile", + desired = desired.as_str(), + error = %e, + "server ready on the shared pool but its pool is unreadable — \ + publishing the gap (no guessed share; retries next tick)", + ); + (0, served_lanes) + } + }, _ => (served_window, served_lanes), }; // The grant the engine was LAUNCHED with: the spawn fact on the control, or — for diff --git a/core/continuum-serving/src/modules/serving_daemon/publication.rs b/core/continuum-serving/src/modules/serving_daemon/publication.rs index 61e2f6c7a1..ec6620f303 100644 --- a/core/continuum-serving/src/modules/serving_daemon/publication.rs +++ b/core/continuum-serving/src/modules/serving_daemon/publication.rs @@ -32,7 +32,7 @@ pub(super) fn verified_capture( if snapshot.active_model.as_deref() != Some(launch.target.model.id.as_str()) || snapshot.adapters != launch.target.adapter_paths() || (snapshot.served_context_window, snapshot.lanes) - != sequence_share(launch.observed_context_window, launch.observed_lanes, launch.target.model.context_window) + != sequence_share(launch.observed.pool_tokens, launch.observed.lanes, launch.target.model.context_window) || snapshot.host_prompt_cache_mib != launch.launched_host_prompt_cache_mib || server.owned_engine()? != launch.identity { diff --git a/core/continuum-serving/src/modules/serving_daemon/tests.rs b/core/continuum-serving/src/modules/serving_daemon/tests.rs index 7444fba221..230c1d3445 100644 --- a/core/continuum-serving/src/modules/serving_daemon/tests.rs +++ b/core/continuum-serving/src/modules/serving_daemon/tests.rs @@ -136,6 +136,10 @@ impl LlamaServerControl for FakeServer { // so the reconcile publishes a READY snapshot carrying a real window. Ok(11008) } + async fn served_pool_tokens(&self) -> Result { + // One sequence's worth of the fixed window above: the share these tests publish. + Ok(11008) + } async fn served_lanes(&self) -> Result { // 0 = "this fake's /props names no slot count", i.e. nothing to compare // on the lane axis. These daemon tests assert the window/readiness path, @@ -284,8 +288,8 @@ pub(crate) async fn exercise_cancelled_exclusive_teacher( prior.adapters = original.target.adapter_paths(); prior.base_url = format!("{root}/v1"); prior.ready = true; - prior.served_context_window = original.observed_context_window; - prior.lanes = original.observed_lanes; + prior.served_context_window = original.observed.context_window; + prior.lanes = original.observed.lanes; prior.host_prompt_cache_mib = original.launched_host_prompt_cache_mib; daemon.serving_tx.send_replace(prior.clone()); daemon.acknowledge_verified_target(&prior, daemon.intent.snapshot().revision);