Skip to content

The engine's pool fits the host and the device; the prompt cache regrows only by measured headroom - #5989

Merged
joelteply merged 3 commits into
canaryfrom
fable/the-pool-fits-the-host
Nov 14, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/the-pool-fits-the-host

Conversation

@joelteply

@joelteply joelteply commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Serves the residents' speed (path step 1, Fast) and the one memory control (CONTINUUM-ENGINE.md); order-of-work line 3b (one live engine, one memory budget). An engine pool that overcommits the host swaps every mind's working set; a cache that flaps re-enters pressure.

Measured (live receipts, M5 64 GB, Qwen3.6-35B-A3B, canary 7a29474 deployed 00:57Z, #5980 + #5981)

  • Before deploy (00:51Z): free 1.7 GB, compressor 22.1 GB, swap 5.9/7.2 GB, OS pressure level 1.
  • Boot reading (memory.pressure at 1794617812455): host_available 52,122 MiB, compressed 1,344 MiB, swap 5,915 MiB, OS Normal.
  • Launch (serving.launch.plan at 1794617823874): stable-arm plan 3 x 207,691, lanes_bound.budget_bytes 46,011,570,176 (= board usable 25,592,004,608 + incumbent weights credited), need 382,706 (serving.launch.await_settle); engine -c 623070 --parallel 5 --cache-ram 8717; context_geometry allocated 623,104.
  • Measured engine cost at that pool (~/.continuum/state/lane-footprint.json): 15,163 B/token, anon 24,969,922,712 B, + 20.69 GB weights. footprint at 01:2xZ: 23 GB dirty; vm_stat wired 2,446,745 pages (40.1 GB).
  • 01:14Z: free 0.1 GB, compressor 34.3 GB, swap 94% (6.77/7.17 GB), memorystatus level 2, memory.pressure deficit 3,915 MiB; acts since deploy Aiko 5, Atlas 3, Benchy 1, Aris 0; decode ~10.6 tok/s.
  • 01:22Z: all 5 slots is_processing (four at n_past 0, one at 707); Aris 4 requests, none completed; embed.vram.refused requested 186,908,672 B at VRAM available 0 (embeddings degrade to no-relevance); swap 9.2/10.2 GB, compressor 28.4 GB, OS pressure 2.
  • The flap: serving.reclaim.prompt_cache at 1794618412459 (8,717 -> 1 MiB, target 26,471,432,192 B, held 0), then serving.prompt_cache.take_again at 1794618421570 (1 -> 8,717 MiB), 9.1 s later.

Cause

  1. core/continuum-serving/src/modules/serving_daemon/launch.rs launch_pool (plan_pool.max(fit_pool).max(held), canary line 771): plan_pool = 207,691 x 3 = 623,073 took the plan whole; engine_pool (canary line 40-42) laid it out as 124,614 x 5 = 623,070. No term read the host's memory or the device's governed budget net of other consumers (the embedder).
  2. continuum-kernel/.../memory_pressure/host_deficit.rs take_again_due (calm_polls >= 2) plus serving_prompt_cache/lever.rs take_back (the whole grant at once): a poll count decided when memory is retaken, and it was retaken in one jump.

Fix

  • serving_daemon/host_fit.rs (new): HostRoom (available + a replaced engine's own bytes - compressed - swap, from continuum_host::host_memory), Rooms { host, device }, PoolFit { Unmeasured, Fits, Bounded { by: Bound::{Host, Device} } }. engine_pool sizes the pool to the seated minds' NEED with the grants' growth margin (need_with_growth: held need x SENT_HEADROOM = 1.25, the margin Demand::of uses, or her own wish/declared size, capped at the trained window, plus the planner's least window per unclaimed sequence; the plan's launch_pool only when nobody is remembered), then caps it by the smaller room via the plan's one cost arithmetic (window_within, measured per-token cost), the host room after the host prompt cache, the device room = governed_vram_ceiling (replace-myself, net of every other consumer's reserved floor) read only when the budget is OwnCredit::Included. Bounded launches probe serving.launch.pool_fit (demand, fit, bound). The minds' grants share the pool by measured need (unchanged grants.rs). floor_sized uses the same fitted pool, so it never relaunches past the host.
  • HostDeficit::observe -> HostDeficitReading { NoVerdict, Calm { headroom }, Owed(NonZeroU64) }: headroom = available beyond the most the OS had available while it last read pressure (never below its free target). MemoryReporter::take_again(headroom) -> claimed; the monitor offers the headroom in turn.
  • Prompt cache: raise by at most headroom less what the current limit has not filled, toward the grant; a raise the cache has not grown into is never raised again.

Review findings on #5981 (~/.continuum/evidence/js-shaped-rust-2026-11-14/review.md) fixed here: #1 typed HostDeficitReading; #29 calm_polls gone (measured headroom); #30 stuck_said latch removed (at-floor is decided synchronously, no probe spam), no catch_unwind as control flow around take_again; low: MachVmCounts.pressure: Option<OsMemoryPressure>, the monitor's 11-field tuple is struct Ingested. #2 partly: the shedder and lever see one absence (grant() -> Option<NonZeroU64>, current_limit total, NoStep::LimitUnknown deleted); the wire field ServingSnapshot.host_prompt_cache_mib: u32 (ts-rs, ~30 sites across engine/serving/core/academy) is left for its own PR, owner Fable, so this one stays reviewable.

Dyno (simulator first; serving_daemon/tests/dyno.rs)

  • Dyno 12 the_pool_fits_the_host: before, launch_pool reproduces 623,073 (-c 623070) and the engine's cost there (48,105,164,561 B by the plan's arithmetic) exceeds the boot room (47,042,265,088 B). After, the pool is the need: 4 held needs summing to 382,706 (the probe recorded the sum; split evenly) x 1.25 + 2,048 scratch = 480,430 tokens, Fits under a room that would hold 566,990 (never filled). Freed vs the recorded launch: 142,643 tokens = 2,162,895,809 B at the measured 15,163 B/token; 1,640,613,306 B left beside the engine for the core, the embedder and the OS. A need past the room is Bounded { by: Host }; a replaced engine's measured 24,969,922,712 B count as room; no reading launches the need.
  • Dyno 13 take_again_flap: before, two OS-normal readings inside the pressure range (4,914-5,979 MiB) carry no headroom, so the old one-jump 8,717 MiB raise had no room; after, lowered to 1 MiB, nothing offered inside the range, then at 8 GB available the cache rises by 1,926 MiB (< headroom), the same offer again raises nothing, and a pressured poll offers nothing: the limits asked are [1, 1927], monotone.
  • host_fit unit tests: the device room bounds a pool host RAM would hold (01:22Z embedder receipt).
  • Dyno 11 now raises within the measured room instead of after two calm polls.

Not built here (no cargo on the serving M5); CI is the compiler.

Limits named: (a) the room counts swap as displaced, so a host with inert swap sizes conservatively; the floor_sized rule is the upward path. (b) serving learns the cache's contents only from /prompt-cache/limit replies, so a raised cache that fills is reported at its last reply until the next shed; owner Fable, next PR on this line. (c) at boot (OwnCredit::ToApply) the device room is not read (the board does not yet hold serving's bytes; reading it then would launch at the floor, the 2,048 regression of card 8569b03d).

Measured after deploy: owner Fable, within the hour after this merges and deploys: on the M5, serving.launch.pool_fit at boot, OS pressure level and compressor at +15 min, embed.vram.refused count, acts/h per resident, and zero serving.prompt_cache.take_again raises above the probed headroom.

Lines: 808 added, 247 removed (tests and docs included; production delta in serving_prompt_cache.rs and lever.rs is net negative).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 2 commits November 13, 2026 19:29
…regrows only by measured headroom

The M5 (64 GB, Qwen3.6-35B-A3B), canary 7a29474: the engine launched at -c 623070
(launch.rs launch_pool took the plan's 3 x 207,691 whole, sized against a 46.0 GB budget)
beside --cache-ram 8717 while the host had room for ~44.9 GB without displacing anyone; the
kernel read pressure within 17 minutes and the embedder's lease was refused at VRAM 0. Then a
deficit lowered the cache 8717 -> 1 MiB and two OS-normal polls 9 s later raised it straight
back to 8717.

- host_fit: the launch pool is the minds' demand fitted to the host's room (available plus a
  replaced engine's bytes, less compressed and swapped) after the host prompt cache, and to the
  device's governed budget when it holds serving's own bytes; Bounded launches say so
  (serving.launch.pool_fit).
- HostDeficit::observe returns HostDeficitReading { NoVerdict, Calm { headroom }, Owed }; the
  headroom is available beyond the most the OS had available while it last read pressure. No poll
  count decides when memory is retaken.
- MemoryReporter::take_again(headroom) -> claimed; the monitor offers the headroom in turn, with
  no catch_unwind as control flow. The prompt cache raises by at most the headroom less what its
  current limit has not filled, toward its grant; the stuck_said latch is gone, one absence for
  the grant (Option<NonZeroU64> at the shedder's seam).
- MachVmCounts stores the typed verdict; the monitor's 11-field tuple is a named struct.
- Dyno 12 (pool fits the host) and dyno 13 (the take-again flap) reproduce the receipts and pin
  the fixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…is only its ceiling

Dyno 12 after the first cut still filled the room (566,990 of the boot's reading for needs of
382,706), leaving the core, the embedder's lease and the OS nothing, the 01:22Z failure. The
demand is now each seated mind's claim (held need x SENT_HEADROOM, the margin Demand::of uses,
or her own wish/declared size) plus the least window per unclaimed sequence; the plan's pool
only when nobody is remembered. Dyno 12: 623,073 before, 480,430 after, 142,643 tokens
(2,162,895,809 B at the measured 15,163 B/token) freed, 1.64 GB left beside the engine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit e3ff331 into canary Nov 14, 2026
40 checks passed
@joelteply
joelteply deleted the fable/the-pool-fits-the-host branch November 14, 2026 02:22
joelteply added a commit that referenced this pull request Nov 14, 2026
…e ratchets

Rule 10/11 text: canary's #5986 wording kept, plus the shape-ratchet section, its
baselines and the correction that time_bounds and wall_clock never counted sleeps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Nov 14, 2026
* The boot counts the device room: computed beside every other consumer's claim, the embed floor outside it

#5989 read the device room only when the board held serving's own bytes, so the boot launch on
the M5 (canary 958ea30, 03:35Z, OwnCredit::ToApply, usable 0) sized -c 661410 with no device
room, and the embed lane's leases were refused at 0 available 12 times in 26 minutes.

- ResourceLeaseLedger::room_beside_others (through the governor and daemon): capacity less every
  other consumer's max(floor, grant, measured residency), computed from claims, never from
  physical_used, so a gap reading (a leaving engine's unattributed bytes) cannot read it as 0.
- device_budget::boot_device_room feeds it to engine_pool at a boot or a gap; the pool is
  min(need, host room, device room) from the first launch.
- Pinned: ledger::tests::the_embed_floor_survives_a_boot_sizing. Dyno 14 from the 03:35Z receipts.

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

* Files this change touches leave with every unwrap justified; reclaim order is a total order

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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