Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/continuum-engine/src/capacity/window_grant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ impl PoolGrants {
}
}

static GRANTS: std::sync::OnceLock<tokio::sync::watch::Receiver<Option<PoolGrants>>> = std::sync::OnceLock::new();

/// Install the serving daemon's grants as the process-wide readable seam, beside
/// `install_serving_state`. Set once; a second call is ignored. `true` iff this call installed it.
pub fn install_grants(rx: tokio::sync::watch::Receiver<Option<PoolGrants>>) -> bool {
GRANTS.set(rx).is_ok()
}

/// Her current grant on this node's engine: `None` before the daemon installs its grants, before
/// the engine serves, or while she has none yet. A `watch` borrow, no I/O.
pub fn current_grant(persona: uuid::Uuid) -> Option<u32> {
GRANTS.get()?.borrow().as_ref()?.grant_for(persona)
}

/// One mind's current demand on the pool: what her next turn requires, and whether a turn of hers
/// is in flight now.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
21 changes: 11 additions & 10 deletions core/continuum-mind/src/persona/supervisor/materialize_adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,24 @@ pub async fn materialize_adapters(
}
} else if profile.tier_category != crate::persona::hw_tier_descriptor::HwTierCategory::Cloud
{
let snap = crate::inference::llama_server::current_serving();
// A ready snapshot always carries a real window (the daemon refuses to
// publish ready with 0). Guard on both so a not-yet-ready/empty
// snapshot never clobbers the provisional window with 0; the re-home
// reconciler corrects the binding once serving is ready.
if snap.ready && snap.served_context_window > 0 {
if snap.served_context_window != profile.context_length {
// Her window is her grant on the engine's pool (`serving_daemon/grants.rs`), never the
// per-sequence share the snapshot publishes (the pool divided by its sequences: 51,507
// on the M5; Cormac on #5733). No grant yet (the engine not serving, or no one on the
// seat measured) keeps her provisional window; the re-home reconciler binds her to her
// grant once she has one.
if let Some(grant) = crate::capacity::window_grant::current_grant(profile.persona_id) {
if grant != profile.context_length {
continuum_base::probe!(
class = "persona.upstart.window",
persona = %profile.persona_name,
persona_id = %profile.persona_id,
planned = profile.context_length,
served = snap.served_context_window,
"pinning persona context window to the gateway's real /props slot (was the drifting plan value)",
served = grant,
source = "grant",
"binding persona context window to her grant on the engine's pool",
);
}
profile.context_length = snap.served_context_window;
profile.context_length = grant;
}
}
// Register the persona's adapter in the global provider
Expand Down
1 change: 1 addition & 0 deletions core/continuum-serving/src/modules/serving_daemon/tick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl ServiceModule for ServingDaemonModule {
// free functions + adapters read "what's live" as a pointer instead of
// each probing /v1/models. Set-once (singleton daemon).
let _ = crate::inference::llama_server::install_serving_state(self.subscribe_serving());
let _ = crate::capacity::window_grant::install_grants(self.subscribe_grants());
// THE DEVICE-BUDGET AUTHORITY, wired here rather than promised in a doc comment.
// Without it `EphemeralServingLane::spawn` admits every engine with only a
// free-port check — which is how three sidecars once shared one GPU. Set-once
Expand Down
Loading