Skip to content

feat(serving): hysteresis — stop live-budget jitter from thrashing the served model - #1648

Merged
joelteply merged 1 commit into
canaryfrom
feat/serving-hysteresis
Jun 16, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/serving-hysteresis

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Follow-up to the serving control plane (#1647). The live memory budget reacts to free memory — which means it can also thrash near a model's edge (free memory jitters → "most capable that fits" flips → model reloads). This adds hysteresis so the organic response is smooth.

What

plan_serving_stable(host, candidates, incumbent) wraps plan_serving:

  • Keeps the incumbent 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 — a transient bump can't flap it.
  • Lanes + resident always re-track the live budget (re-ranks the incumbent to top, reuses plan_serving's logic — no duplication).

The daemon's publish_plan passes the currently-served model (from the watch) as incumbent; boot's first plan has none → plain selection.

Why it matters on all machines

Preemptive on the M5 Pro (headroom), but exactly what stops model-flapping on the 8GB Air where models sit near the edge. It's also the local-serving half of a 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, and it becomes load-bearing when serving reacts to grid peer-liveness for cross-grid inference routing.

Tests (4, all 14 serving green)

no-incumbent==plain · keeps-incumbent-without-headroom (the thrash guard) · upgrades-with-headroom (not a lock-in) · forced-down-when-unfit.

🤖 Generated with Claude Code

…e served model

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]>
@joelteply
joelteply merged commit 90e64ee into canary Jun 16, 2026
4 checks passed
@joelteply
joelteply deleted the feat/serving-hysteresis branch June 16, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant