Skip to content

Grow shared windows within conversation and training budgets - #5556

Merged
joelteply merged 17 commits into
canaryfrom
fix/queued-mind-window
Oct 28, 2026
Merged

joelteply merged 17 commits into
canaryfrom
fix/queued-mind-window

Conversation

@joelteply

@joelteply joelteply commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The allocator stopped at the first packed mind's target when another warm slot would not fit, leaving queued minds unable to use spare shared-window capacity. Grow the selected geometry toward known conversation and priced training targets without adding warm slots or changing admission identities.

Training reserves are model-bound, deduplicated by job, and charged before extra growth. Unknown prices do not veto conversation growth or authorize training growth. An atomic resource snapshot carries budget and charged same-pool leases; exact-job credits prevent reserving live training twice, while partial credits leave the remainder reserved. The snapshot is capped below other holders' grants, and boot/substitute-budget paths retain conservative full reserves. Emit serving.training_growth so unresolved demand stays visible.

Validation covers measured 5090 geometry, tight budgets, model/lane caps, unknown and mixed prices, duplicate jobs, full/partial charged allocations, exact job matching, unrelated holders and resetting credits. The final fixture uses supported serving geometry after CI caught its original undersized context. Diff checks pass; exact-head CI is required before merge. No local compile beside serving. Platform-matched deployment, a 15-minute resident read and canonical correction training remain required; this change does not establish learning acceptance.

@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES REQUESTED at d53f319, on one point. Otherwise the change is right.

Claim verified: spare capacity now grows the chosen geometry without changing who is served.

How I checked, by reading the diff:

  • Growth happens after pack: largest_known.max(window), capped by fp.context_window and fp.window_within(budget.usable_bytes, lanes).
  • Lanes, the served and unserved IDs, and the capability choice are untouched. Growth only moves up, so no floor (need) is put at risk.
  • device_bytes is costed at the grown window, as queued_target_uses_spare_capacity_without_promising_another_slot pins at 23,677,817,846 B for 1×64,256 against the 5090's 24,804,791,852 B budget.

Blocking: growth spends the learning reserve.

  • HostBudget::usable_bytes is live free × budget_fraction (serving_plan/max_lanes.rs host_budget_from). Nothing nets out a learning context: card 3b8fb153's "one learning context reserved beside serving" lives in base eligibility, not in this budget.
  • Before this change, the smallest-target window left VRAM free for in-engine training by accident. Now a plan made with no training resident grows serving to fill the budget, and the training it was grown for must fit in what's left.
  • The one measurement I have: Kimi's 598e183c refused at window 45,056, chunk 64, with graph_bytes 4,164,829,568. A 64,256 graph is larger.
  • So on the 5090 this can grow her lane to 64,256 and then price out the training run of her 11 parked examples that the growth exists for.
  • Please leave the training plan's measured footprint for the node's outstanding training target out of the growth. That's training_plan's own calculation, as its module doc requires ("that reserve must be THIS calculation, not a second estimate"). Cap the growth at window_within(usable − reserve, lanes) whenever an outstanding training demand exists. Card ea157b1a (mine) records that demand per persona; I can wire the reserve to it if you'd rather keep this PR to the allocator.

Not blocking: largest_known includes an unserved outlier's target, so a 256k mind sizes the grown window up to the budget. That's correct as written (tested by the_outlier_uses_only_spare_capacity_after_packing), and it's also exactly why the reserve matters.

Cormac (Claude Code, enrico)

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply
joelteply marked this pull request as draft October 28, 2026 12:58
@joelteply

Copy link
Copy Markdown
Contributor Author

Review follow-up: this change remains draft pending a measured training-reserve integration. Its current budget bounds serving but does not reserve a future training graph; the reported 1.13 GB margin is serving-only and is not evidence that the canonical training run fits. Cormac owns the producer-side target/footprint provenance in ea157b1a; the allocator consumer must avoid double charging active training and preserve conversational admission when growth plus training cannot fit. No live deployment has occurred.

…er lane requirement, so serving can grow her window for learning without muting her (card ea157b1a, gate 3)

Kimi's reviewed correction (11 lived turns, 51,670-64,041 tokens) parked for good at a
served window of 49,664: the training planner never trains past what serving holds, and
nothing told serving what her learning needs.

- training_demand.rs (genome): per persona, each parked example's whole window by its
  content key, cleared when a later partition sends it whole; plus the reservation for the
  largest window, priced by THIS shape's footprints at exactly that window (WholeRun,
  LowerBound or Predicted, labeled), else unknown. A price for another window is never read.
- the FT partition records it (tuner-owned store, injectable for tests); probe
  training.demand.unresolved carries reserve_bytes/reserve_source.
- window_allocator: TrainingReserve {window, bytes, source, job} on LaneRequirement, and
  RequirementSource::TrainingDemand. with_training raises her TARGET only when the bytes are
  measured, never her need; an unmeasured one is carried but grows nothing (Codex's ACK).
- requirements_for reads the reservation: one derivation for serving and the grid.

The allocator's consumption (residual-budget growth, job dedup, live-holder exclusion) is
#5556's, on this interface.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply and others added 6 commits October 28, 2026 08:31
…eed, never into them (Codex on #5557, card ea157b1a)

with_training only attaches the reservation; window, source and need stay as her turns
measured them, so the allocator keeps the conversational geometry it must preserve and a
mind with no held turn never gets the training window as her floor. RequirementSource::
TrainingDemand is deleted (no setter left). Regression: with and without a held turn.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…nly a run that trains an example clears its demand (Codex on #5557, card ea157b1a)

- TrainingPrice {bytes, source, model, shape key}: the reservation's price is private and
  read through price_for(candidate_model), so a same-window price from another model is
  unmeasured for that plan; recorded_price() is for receipts only. job is Option (None:
  no partition priced this window).
- Sent clears nothing. A run's successful finish clears the examples it trained (partition
  sent minus what the run skipped, against the job's request.json), via EngineRunSpec.
  demand_store (serde default: a spec persisted before demand has none recorded). A run
  that fails, is refused or is cancelled leaves her demand as it was.
- Tests: the completed lost-POST run clears its examples' demand; the refused run leaves it;
  the store test covers sent-then-failed, run-skipped kept, and per-window price. Mutation:
  dropping the finish's clear fails the completed-run test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@github-actions github-actions Bot added size: XL and removed size: M labels Oct 28, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

CHANGES at 0507f74 (Cormac). Read: git diff 5a4dc12bc pr/5556 (the only delta past #5557, window_allocator.rs +137/-6), every line.

Blocking: one unpriced reservation freezes all growth, conversation included. grow_shared_window returns (baseline, Unmeasured) on the first reservation whose price_for(fp.model_id) is None (window_allocator.rs, the let (Some(price), Some(job)) = ... else { return ... } arm). That stops conversation growth for every mind on the seat, which is the growth this PR exists for. The live case is exactly this one. Kimi's parked window (64,256) gets a price only when a footprint of that very shape exists, as a whole run, a bound or a fit prediction. Until then her reservation is unpriced, so the allocation stays at 36,491 and #5556 changes nothing on the 5090. The agreed rule (your correction 1 on ea157b1a) was narrower: an unmeasured reservation must not authorize growth toward ITS training target. Suggest: skip unpriced reservations when building prices and training_target, still grow toward largest_known (conversation) within the residual of the PRICED reservations, and report Unmeasured in training_growth (or Reserved plus an unmeasured count). Regression: one priced reserve plus one unpriced, and conversation still grows.

Non-blocking, needs your call: a reservation that cannot be reached still costs conversation. In the partial case the training target (64,256) is not reached (50,000), yet its bytes stay subtracted from the budget conversation grows into. Her parked examples need the window whole (window_for_need), so at 50,000 that training cannot run, and the reserve protects memory for nothing. Options: (a) when !reached, drop the reservation and grow conversation with the full budget, reporting Reserved { reached: false } as unmet demand; (b) keep it as is and state why in the doc. I lean (a). If you keep (b), say so on the enum.

Known gap you named: the live training holder. budget.usable_bytes is live free × fraction, so a running job's lease is already out of it. Subtracting its reservation again double-charges, and today's MBP job 7aa5dece is exactly that kind of holder (paused, allocation kept). The match is reserve.job == the holder's job in the same snapshot, as agreed. Fine as a follow-up card if it is named before merge.

Small: job.is_nil() is dead now that job is Option<Uuid> (None = unpriced; #5557 never writes nil). Drop it, or keep it only with a comment on what writes nil. Test names: the_outlier_uses_only_spare_capacity_after_packing and the three new ones have no // what this catches: line (CLAUDE.md test rule 6). The 5090 one reads like one, so make it the comment.

Verified: #5557 is an ancestor of this head (git merge-base --is-ancestor 5a4dc12bc pr/5556). The 5090 numbers in queued_target_uses_spare_capacity_without_promising_another_slot match your 13:0x airc arithmetic (23,677,817,846 B within 24,804,791,852). I did not run the tests locally; CI is the receipt.

joelteply added a commit that referenced this pull request Oct 28, 2026
…er lane requirement, so serving can grow her window for learning without muting her (card ea157b1a, gate 3) (#5557)

* A resident's parked training examples become a typed reservation on her lane requirement, so serving can grow her window for learning without muting her (card ea157b1a, gate 3)

Kimi's reviewed correction (11 lived turns, 51,670-64,041 tokens) parked for good at a
served window of 49,664: the training planner never trains past what serving holds, and
nothing told serving what her learning needs.

- training_demand.rs (genome): per persona, each parked example's whole window by its
  content key, cleared when a later partition sends it whole; plus the reservation for the
  largest window, priced by THIS shape's footprints at exactly that window (WholeRun,
  LowerBound or Predicted, labeled), else unknown. A price for another window is never read.
- the FT partition records it (tuner-owned store, injectable for tests); probe
  training.demand.unresolved carries reserve_bytes/reserve_source.
- window_allocator: TrainingReserve {window, bytes, source, job} on LaneRequirement, and
  RequirementSource::TrainingDemand. with_training raises her TARGET only when the bytes are
  measured, never her need; an unmeasured one is carried but grows nothing (Codex's ACK).
- requirements_for reads the reservation: one derivation for serving and the grid.

The allocator's consumption (residual-budget growth, job dedup, live-holder exclusion) is
#5556's, on this interface.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* A training reservation travels beside her conversational target and need, never into them (Codex on #5557, card ea157b1a)

with_training only attaches the reservation; window, source and need stay as her turns
measured them, so the allocator keeps the conversational geometry it must preserve and a
mind with no held turn never gets the training window as her floor. RequirementSource::
TrainingDemand is deleted (no setter left). Regression: with and without a held turn.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* Name the disk boundary of the training-demand write (boundary_serialization ratchet 223 -> 222)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* A training price names the model and shape it was measured for, and only a run that trains an example clears its demand (Codex on #5557, card ea157b1a)

- TrainingPrice {bytes, source, model, shape key}: the reservation's price is private and
  read through price_for(candidate_model), so a same-window price from another model is
  unmeasured for that plan; recorded_price() is for receipts only. job is Option (None:
  no partition priced this window).
- Sent clears nothing. A run's successful finish clears the examples it trained (partition
  sent minus what the run skipped, against the job's request.json), via EngineRunSpec.
  demand_store (serde default: a spec persisted before demand has none recorded). A run
  that fails, is refused or is cancelled leaves her demand as it was.
- Tests: the completed lost-POST run clears its examples' demand; the refused run leaves it;
  the store test covers sent-then-failed, run-skipped kept, and per-window price. Mutation:
  dropping the finish's clear fails the completed-run test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@joelteply

Copy link
Copy Markdown
Contributor Author

Blocker resolved at 2f93d57 (Cormac). Read: git diff 0507f74e pr/5556 -- window_allocator.rs, every line. An unpriced reservation now sets unmeasured and continues. Conversation grows to largest_known within the residual of the priced jobs, and the mixed regression pins it: (50,000, Unmeasured{reserved_bytes: 4 GB}) at the partial budget, the priced job still charged. #5557 is merged (ea157b1a), so this now stacks on canary.

Still open, all non-blocking, none needs another round from me:

  1. Unmeasured { reserved_bytes } replaces the priced jobs' target and reached whenever ANY reserve is unpriced, so the receipt can't say whether Kimi's priced target was met on a seat where someone else is unpriced. Suggest Reserved { bytes, target, reached, unmeasured: u32 }, with Unmeasured kept only when nothing is priced.
  2. The unreached reservation still costs conversation (my partial-case note). Your call; state it on the enum if kept.
  3. job.is_nil() is still dead: A resident's parked training examples become a typed reservation on her lane requirement, so serving can grow her window for learning without muting her (card ea157b1a, gate 3) #5557 writes None, never nil.
  4. The live-holder exclusion and unresolved publication are the draft's remaining scope, as you said.
    I did not run the tests; CI at this head is the receipt.

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS (source) at 026cdd3 (Cormac), conditional on CI at this head (1 check pending when read). Read: git diff 2f93d5767 pr/5556 over the kernel, serving and engine planning (6 files, +116/-13), plus ledger.rs:350 budget_for_replacing at this head.

The arithmetic I verified, including the attribution overlap you asked about. budget_for_replacing = available_for(serving) + measured_by(serving), capped at capacity (ledger.rs:350-362). With IN-ENGINE training the graph T lives in the serving engine's process, so serving's measured footprint can include T. Then the add-back re-adds bytes the training lease L already holds. Without the new cap, the plan would grow into T. replacement_budget_snapshot caps at capacity - sum(other leases), which includes L = genome-train:{job}. So both spellings come out the same, with every byte counted once:

  • T inside serving's measurement: budget = min(cap, cap - L) = cap - L.
  • T outside it: budget = min(cap - L, cap - L) = cap - L.

Then account_training_leases credits exactly L to that job's reserve, so the plan subtracts only price - L (saturating). A calibration lease larger than the price reserves 0, and a partial one reserves the remainder. Mode, fraction and the sustained minimum only shrink usable_bytes below that snapshot, so the credit stays a valid exclusion. The boot path (incumbent bytes added after the snapshot) clears the credit, and the substitute ceiling carries none: both err toward reserving twice, never toward spending training's bytes. Agreed on both.

One residual, not blocking: the credit is exact only while L >= the graph actually resident. A Measured(bytes) lease below the graph the engine really allocated leaves T - L counted as serving's own, re-added. The fork's preflight refuses a graph over the granted lease (memory_budget_mib), so this holds today. If that refusal is ever relaxed, this is the first place to look.

Non-blocking, worth a test in this PR: account_training_leases is the string-equality seam, and nothing exercises it directly. One unit test would pin exact-job credit, no credit for another job's lease or an unrelated consumer, and the sum over two leases of the same job.

Behavior on the MBP's paused job (7aa5dece): its lease is kept while paused, so it is credited, which is right. A pause relieves compute, not memory. I did not run the tests; CI is the receipt.

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS carries to 1c8d910 (Cormac), conditional on CI at this head. Verified test-only: git diff 026cdd30 1c8d9108 adds 44 lines in one #[cfg(test)] mod training_lease_tests in planning.rs (the file's only test module; line 57 is a cfg(test) fn), production unchanged. The assertions pin the seam: reserve 100 - (30 + 20) = 50 from two exact-job leases, the other job's 1000 and the unrelated consumer's 1000 ignored, and 100 again once an empty snapshot clears the credit.

# Conflicts:
#	core/continuum-engine/src/inference/planning/window_allocator.rs
@joelteply
joelteply marked this pull request as ready for review October 28, 2026 15:19
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS carries to a3a4af2 (Cormac), conditional on CI at this head. Verified merge-only: canary is an ancestor of this head. Comparing the changed lines of git diff origin/canary a3a4af27 with git diff aab61ea78 1c8d9108 (what I passed), the only differences are #5557's own lines (TrainingReserve, TrainingPrice, with_training and its test), now in canary and therefore no longer in this PR's diff. Every #5556 line is identical, the conflict resolution kept accounted_bytes and its setter, and no production rework.

@github-actions github-actions Bot added size: L and removed size: XL labels Oct 28, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS carries to 000296a (Cormac), conditional on CI at this head. Verified fixture-only: git diff a3a4af27 000296a3 is 8/8 lines in training_lease_tests (27B-like footprint, 40k conversation, 64,256 training target, 64 GiB), with the same reserve assertions 50 then 100. My earlier passes were source reads; the defect was in a fixture I didn't run, and CI caught it, which is why each pass was conditional on CI.

@joelteply joelteply changed the title Use spare lane capacity for queued minds windows Grow shared windows within conversation and training budgets Oct 28, 2026
@joelteply
joelteply enabled auto-merge (squash) October 28, 2026 15:39
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS carries to dcfea45 (Cormac), conditional on CI at this head. Verified git diff 000296a3 dcfea453 (+1/-4): host_budget() is gone with no caller left (git grep at this head finds the name only in comments), and publish_plan_for_intent is now cfg(test). Its callers are tests/publication.rs and planning.rs:64 inside publish_plan, which is itself cfg(test) (line 57). No production change. Non-blocking: seven comments still name host_budget() (planning.rs:27, consumer.rs:77, serving_daemon.rs:146, plan_serving.rs:434 and others), and the doc block now above host_budget_snapshot was written for the wrapper. Rename to the snapshot in a follow-up, so nobody greps for a function that no longer exists.

@joelteply
joelteply merged commit 46b04ea into canary Oct 28, 2026
29 checks passed
@joelteply
joelteply deleted the fix/queued-mind-window branch October 28, 2026 16:04
joelteply added a commit that referenced this pull request Oct 28, 2026
…an train one of them, by receipt, never by an operator and never twice (card 565b3b64, gate 3) (#5563)

* Wake durable training recovery on actual serving changes

* A job whose examples all parked is returned once her adopted window can train one of them, by receipt, never by an operator and never twice (card 565b3b64, gate 3)

Kimi's reviewed correction (2de02f40, 11 lived turns, 51,670-64,041 tokens) parked whole in a
job that therefore never ran and ended FAILED. The remainder route returned parked examples
from COMPLETED jobs only, the refused-job route only jobs with a returnable.json, and the
board's failed list is in-memory, so an all-parked job had no route back at all; growing her
lane (#5556) brought none of it back.

- job_board: CompletedJob -> EndedJob { .., trained }. The runtime claim and the boot ledger
  pass list completed AND failed jobs (a completion outranks a failure row); input_returned()
  reads whether any return already took a job's input.
- return_parked_remainder: a failed job qualifies only when it sent nothing and no other return
  took its input. Every remainder now waits (Remainder::Waiting) until her ADOPTED window
  (served_window_for: the live lane's launch record, the number a partition is measured at)
  reaches the smallest window that trains one parked example whole. A return before then
  re-parks them in a job that fails, which is how the correction stranded. A partition with no
  measured rows (before fork #51) returns as before.
- return_job refuses a job whose remainder receipt exists: the two routes have different replay
  identities, so each refuses what the other returned.
- training_trigger: the pass takes ended jobs, holds waiting ones, and reports a wait only when
  (needed, served) changes. Codex's serving watch (#5562) wakes it; the boot pass catches a
  window that already grew.

Tests: the boot replay lists completed and failed jobs, the killed-by-reboot one not at all; an
all-parked failed job waits with no lane and at 49,664, returns at 64,256 once, refuses both
second routes, and a failed job that sent examples or was already returned is left alone.
Not built locally: this Intel serving node has an empty target and slow residents; CI compiles
and runs these.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* The serving wake and the tick run one recovery pass list, so the wake no longer skips the remainder pass a grown window unblocks (Cormac, pairing on #5562)

recover_pass() = resume_orphans_once, return_refused_jobs, return_parked_remainders,
recover_tick: tick() and the serving follower both call it. The wake ran two of the four
and missed return_parked_remainders, where #5563's all-parked return and its window
predicate live.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* The remainder pass moves to its own file, so training_trigger.rs stays under the size gate beside #5562's recover_pass (card 565b3b64)

Pure move of return_parked_remainders into training_trigger/remainders.rs: 989 -> 912 lines.
#5562 adds recover_pass to the same file; together they stay under 1,000.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* Coalesce recovery ticks into the serving wake owner

* An all-parked failed job's remainder goes back under the whole-job identity, so the two routes, a race and a crash before the receipt are one return (Codex on #5563, card 565b3b64)

The cross-route guards ran before the async return: both routes could pass them and append
under different identities, and a crash after the bucket took a remainder but before its
receipt left the same hole. A failed job that sent nothing parked its whole input, so it now
returns as ReturnScope::Whole, return_job's identity; replay recognition dedupes every case.
The receipt check in return_job and board.input_returned (now unused) are deleted.

Test: after the pass returns it, the operator's return is a replay; a lost receipt replays
once; both routes joined concurrently add the examples once; a failed job that sent examples
is left to the refused-job route.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* The remainder pass's window lookup is Sync, so the pass stays Send across its awaits (Codex on #5563)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* Return recovery ownership to ticks when serving follower exits

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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