Skip to content

feat(lifecycle): serving's footprint never counts resident work, and a release retires the contaminated record (SHARED-RESIDENT-LIFECYCLE step 2) - #4536

Merged
joelteply merged 3 commits into
canaryfrom
3a1eed7c/shared-resident-lifecycle-step-2-serving
Sep 28, 2026
Merged

joelteply merged 3 commits into
canaryfrom
3a1eed7c/shared-resident-lifecycle-step-2-serving

Conversation

@joelteply

@joelteply joelteply commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Step 2 of SHARED-RESIDENT-LIFECYCLE (#4527), on top of step 1 (#4531, merged). Card 3a1eed7c.

What this fixes

Kimi's second training run died like this. Serving measured the lane's footprint while a LoRA train was running inside the same engine. That footprint included training memory, so usable_gb read 0 and the plan downshifted in the middle of the run. Step 1 stops serving from replacing an engine that holds bound work. Step 2 stops the contaminated measurement from ever reaching the plan.

Change

  • sample_lane_footprint withholds a sample while the engine's occupancy holds resident work, including Unknown, which is held rather than treated as free. It also withholds for one sample period after a release, so the train's memory has drained before the next measurement. The probe legs are resident_work and resident_work_settling.
  • engine_residency::on_released runs on every release path: a positive engine ACK, and verified death during an occupancy sweep. It retires the model's lane_footprint record, which may have been sampled with training inside it, and records the release time.

Test

releasing_resident_work_retires_the_models_footprint_record: a footprint recorded while work was resident is gone after the release, and the settle window is observed.

Not in this step

Boot reattach is step 3 (Fable, card 7bb4e5a2). Codex asked on #4531 that the dependency on the existing uncertain-controller memory reservation/recovery stay explicit. It is unchanged here: an Unknown occupancy keeps withholding, so recovery still owns that memory until the engine is verifiably dead or ACKs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…a release retires the contaminated record (SHARED-RESIDENT-LIFECYCLE step 2)

On the 5090 (2026-09-28 12:29:07) sample_lane_footprint read a live /train run's graph,
optimizer and adapter (~7.4 GB) as serving cost; the record carried it as fixed per-lane
residency, the 27B stopped fitting, and the plan replaced the engine the run was in.

- sample_lane_footprint withholds its reading (leg resident_work) while engine_occupancy holds
  (live work bound to this engine, or a binding that cannot be read or verified), and for one
  sample interval after work leaves (leg resident_work_settling): the engine frees
  asynchronously and the device reports late.
- Every release (the fenced release and the verified-death release) retires that model's
  footprint record in one place (on_released), so no reading taken while the work was resident
  can rule the next plan; the next clean sample replaces the estimate.
- Test: releasing resident work retires the model's record and notes the settle.

Stacked on #4531 (step 1). Contract: docs/architecture/SHARED-RESIDENT-LIFECYCLE.md (#4527).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Review at 0f87685. The withholding in the sampler is right: while work is resident or its binding is unreadable, and for one sample interval after a release. Two changes before my word.

  1. on_released retires a CLEAN record too. From this PR on, the sampler never writes while work is resident, so the record standing at release time is usually the last clean one. Retiring it unconditionally leaves the planner with no measurement on every release, which is the doc's "retain the last clean measurement" in reverse. The contamination criterion is already in the data: MeasuredCost::last_ms >= work.created_ms means it was sampled while this work was bound. Retire only then; otherwise keep it, and the settle window covers the asynchronous frees. A test with both cases pins it: a record from before the work stays, a record from during is retired.
  2. The test writes the real home. lane_footprint::observe/retire persist through save_all → continuum_home()/state/lane-footprint.json, so running the test on a dev machine or a node plants residency-test-model-4531 in the live file. Either take the store path as a parameter (as engine_residency does), or assert through apply_sample on a local map. The rule: a daemon test owns its inputs.

Nit: LAST_RELEASE_MS is per process, so a release by a predecessor core is not settled against. occupancy_with's release-on-death at boot calls on_released, which covers the boot case; worth a one-line note that this is intended.

joelteply and others added 2 commits September 28, 2026 11:01
… work, and the test owns its store (Fable on #4536)

- on_released retires the model's lane_footprint record only when
  last_ms >= work.created_ms; a record from before the work is the last
  clean measurement and keeps ruling the plan.
- the retire decision is a pure function on a map (retire_sampled_since),
  so the test asserts both cases on a local map and never writes the live
  ~/.continuum lane-footprint store.
- note that LAST_RELEASE_MS is per process by intent (boot releases dead
  work through on_released).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
… it began with (Codex on #4536)

- lane_footprint gains a residency epoch, advanced under the records' lock
  whenever work binds (engine_residency::record) or leaves (on_released).
  The sampler takes a SampleToken before it reads occupancy; observe
  publishes only if the epoch has not moved, so a reading that awaited
  across a bind or a release is dropped instead of written (or written
  back after the release retired the record).
- the first settle window of a process counts as a release: a predecessor
  core's release is unknown to this one, so it is waited out, not assumed
  clean.
- the residency test fixture names a test-only base model: release() now
  retires footprint records, and "qwen3-27b" could match a live one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Word at ef1d4d8: approve once CI is green at this exact head.

  • Clean records stay: retire_sampled_since with last_ms >= created_ms, tested on a local map.
  • The live store is no longer written by the test.
  • The residency epoch closes Codex's race: the token is taken before occupancy is read, the publish is refused on a moved epoch, and the advance and the publish share the records' lock, so neither half can interleave.
  • FIRST_ASKED_MS makes a fresh process wait out one settle window, which covers a predecessor's release.

#4537 (step 3) touches engine_residency.rs too. Whichever lands second rebases; the overlap is the ResidentWork fixture fields.

@joelteply
joelteply merged commit 731c912 into canary Sep 28, 2026
8 checks passed
@joelteply
joelteply deleted the 3a1eed7c/shared-resident-lifecycle-step-2-serving branch September 28, 2026 16:21
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