Repository navigation
feat(serving): serving control plane — classifier + ever-present ServiceModule daemon - #1647
Merged
Merged
Conversation
…ssifier The decision brain for "make this machine work well" with NO grid assumed: a deterministic, classification-based planner (NOT an LLM — per Joel, "we can do better with just classification") that, given THIS host's honest memory budget + candidate model footprints, decides which base model to serve, how many continuous-batching lanes (n_seq_max), and how many models to keep warm. - Degrades across the whole range the substrate must run on: an 8GB M2 Air picks the most capable model that *fits* (not the biggest, not nothing); a 64GB M5 Pro runs the most capable model at up to MAX_LANES=4 lanes with several models resident. - Footprint-aware: a rich coding model (sentinel / full persona) costs more, so fewer fit and fewer lanes run — fatter per-lane KV → fewer lanes. - GPU-residency-first: a model that can't fit even one lane on the GPU/UMA budget reports fits_on_gpu=false and names the smallest option, leaving the CPU-exception (lone Intel Mac) or grid-routing decision to the caller. No silent CPU fallback. Pure function, same shape as adaptive_throughput + model_resolver. Composition seam: lanes → ThroughputLaneBudget::max_concurrency; base_model_id → the spawner's model pick (replacing the hardcoded plan_for_tier path). Loads nothing, schedules nothing — re-run on host-budget change (eviction, pressure). 6 tests: tiny-box-fits-most-capable, big-box-uses-headroom, MAX_LANES cap, footprint-aware lane count, honest no-silent-CPU degrade, empty→None. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… serving_plan The concurrent ServiceModule that decides, and re-decides every tick, how THIS host serves persona inference — the "ebb and flow" loop Joel described, on the Rust core, cbar-shaped (tick-driven, no bespoke thread, watch-published state). On each tick it takes an honest host snapshot (GPU/UMA budget at 80% headroom + the model footprints actually on disk) and runs the serving_plan classifier, publishing the ServingPlan (base model / lanes / warm count) on a watch channel for the scheduler + spawner to consume, and answering `serving/plan` so personas and operators can inspect the decision + its rationale. - Footprint-aware candidates from the registry: weights = real GGUF file size (honest); per-lane KV + capability rank are coarse, clearly-labelled estimates refined later when the registry carries arch internals. Only on-disk models are offered (no serving what isn't present). - GPU-residency-first: no on-disk model → publishes None, says so loudly (the spawner gates on a model; no silent CPU serve). Verified LIVE on the M5 Pro: registered as `serving-daemon`, first plan picks `qwen3.5-4b-code-forged` (most capable on disk, ToolUse → top rank), lanes=4, resident=2, fits_on_gpu=true, usable_gb=44; tick loop running at 5s. ServingPlan gains Serialize (for the `serving/plan` command). 3 daemon tests (headroom math, footprint-awareness, watch publish incl. no-silent-serve) + the 6 classifier tests all green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…from the daemon The persona spawn path now OBEYS the serving daemon instead of hardcodes. The daemon is the single hardware authority: it detects the tier (drives n_gpu_layers — retires the hardcoded CpuOnly+Compat of TODO #52, supersedes the #1645 clamp fix) AND decides the base model + continuous-batching lanes from an honest budget + on-disk footprints with GPU-residency. Threading via the existing data flow (no new control coupling): DesiredRole.lanes → RosterEntry.lanes → build_profile(n_seq_max) → profile. - `PersonaSpawnerModule::with_serving(base_model, lanes)` overrides the tier roster from the live plan; `plan()` applies it. - `ServingDaemonModule::compute_plan()` + `detected_tier()` feed the boot wiring in ipc/mod.rs (one detection source for both tier and model/lanes). - `build_profile` takes `n_seq_max` (floored at 1), replacing the hardcoded `1`. Verified LIVE on the M5 Pro: "serving daemon drives persona spawn base_model=qwen3.5-4b-code-forged lanes=4 resident=2 tier_id=apple-mseries-pro" → persona hosted on the 4B, apple-mseries-pro tier (GPU), profile n_seq_max requested=4. Honest limitation (next lever): the llama.cpp adapter's batching_probe clamps qwen35 to effective=1 lane ("architecture not safe for multi-seq batching") — so 4 lanes are REQUESTED + threaded correctly but only 1 runs until qwen35 multi-seq batching / shared-base (#122) lands. Control plane done; data-plane multi-lane is the follow-up. Tests: +detect_tier_classifies_silicon; build_profile/RosterEntry/DesiredRole test sites updated for the lanes field. All serving + spawner + profile_builder tests green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The serving daemon's budget was static (total VRAM * 0.80). Now it reads the LIVE free memory from SystemResourceMonitor (`available_bytes`), capped at physical VRAM — so the plan responds to real conditions instead of capacity. Why this matters (Joel's example): if someone's playing a video game (or a build / renderer grabs memory), free memory drops, the budget shrinks, and the plan organically picks fewer lanes / a smaller model / pages out; when the load clears, free memory rises and it flows back. No manual config — the substrate feels its own pressure. This is holistic BY SIDE-EFFECT: `available_bytes` is already net of every other consumer (TTS, STT, classifier CNNs, Bevy renderers, other apps), so serving from "what's actually free" respects them. The next refinement is negotiating an arbitrated SHARE from the PressureBroker (the holistic arbiter across all those consumers) rather than reading raw free memory — and reacting on pressure-watch edges faster than the 5s tick. - `host_budget_from(available_bytes, total_vram_bytes, perf_cores)` — live free, capped at VRAM, headroom applied. - `ServingDaemonModule::new(gpu, system)` takes the monitor; registered after it. Verified LIVE: budget tracked 44GB → 27GB across two ticks as free memory moved; spawn still driven (4B, 4 lanes, apple-mseries-pro). Tests updated for the live signature (host_budget_tracks_live_free_memory: less free → smaller budget, capped at VRAM). All serving tests green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…frame The precedence-winning statement of what the grid is for and the invariants every mechanism serves: one grid per owner (GH identity = the boundary fence, not a citizen token); every citizen a unique identity (persona = a user, like a Claude tab; each agent context = a new identity = a home directory of state); reachable the same way over Tailscale; personas are real (real model, real cognition, Docker, no Node); self-grounding not env-fed; survives reboot. Identity-home vs git work-sandbox kept distinct. North star: full human-grade identity per citizen (email/passkey/GH) — current light token is the simple rung, not a ceiling. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This was referenced Jun 16, 2026
joelteply
added a commit
that referenced
this pull request
Jun 16, 2026
…e served model (#1648) The live memory budget (#1647) reacts to free memory, which means it can also THRASH near a model's edge: free memory jitters a few hundred MB, the "most capable that fits" pick flips to a bigger/smaller model, and the served model reloads — churn, not organic response. This adds hysteresis so the response is smooth on all machines (matters most on the 8GB Air, where models sit near the budget edge; preemptive on the M5 Pro's headroom). `plan_serving_stable(host, candidates, incumbent)` wraps `plan_serving`: - Keeps the incumbent model while it still fits the budget. - Switches DOWN only when the incumbent no longer fits (forced eviction). - Switches UP only when a strictly more capable model fits with SWITCH_UP_HEADROOM (10%) to spare — so a transient budget bump can't flap. - Lanes + resident always re-track the live budget (re-ranks the incumbent to the top and reuses plan_serving's fit/lane/pack logic — no duplication). The daemon's `publish_plan` passes the currently-served model (from the watch) as the incumbent; boot's first plan has no incumbent → plain selection. This is also the local-serving half of the cross-grid lesson from coordinating with BIGMAMA: their airc 60s-TTL-vs-120s-publish beacon flap is the SAME class (a liveness signal jittering a decision); hysteresis is how a consumer absorbs it. Becomes load-bearing when serving reacts to grid peer-liveness for cross-grid inference routing. 4 tests: no-incumbent==plain, keeps-incumbent-without-headroom (the thrash guard), upgrades-with-headroom (not a lock-in), forced-down-when-unfit. All 14 serving tests green. Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The serving control plane (this machine first, no grid assumed): a deterministic decision kernel + the concurrent ServiceModule that runs it in an ebb-and-flow loop. cbar-shaped (per CONCURRENCY-STYLE-GUIDE).
1.
cognition::serving_plan— the decision kernelPure, classification-based (NOT an LLM — per Joel: "we can do better with just classification"): honest
HostBudget+ModelFootprints →ServingPlan { base_model, lanes, resident_models, fits_on_gpu }.MAX_LANES=4, GPU-residency-first (no silent CPU fallback).2.
ServingDaemonModule— the ever-present loopServiceModule with a
tick_interval; the runtime drivestick(). Each tick: honest host snapshot (GPU/UMA @ 80% headroom + on-disk model footprints) →plan_serving→ publishServingPlanon awatchfor the scheduler/spawner, and answerserving/planfor personas/operators to inspect the decision + rationale.Verified LIVE (M5 Pro)
Honest assessment → most-capable on-disk model, 4 lanes, 2 warm, GPU-resident, re-decided every 5s.
Tests (9, all green)
6 classifier (tiny/big box, MAX_LANES cap, footprint-aware lanes, no-silent-CPU degrade, empty) + 3 daemon (headroom, footprint-awareness, watch publish incl. no-silent-serve).
Next slices
Consume the published plan: un-hardcode
n_seq_maxfromplan.lanes, drive selection fromplan.base_model(folds in #1645's intent), shared base #122, pressure-broker-driven re-plan + eviction, then grid negotiation.🤖 Generated with Claude Code