Skip to content

Readiness: one parent for the parts that get the next mind ready - #6303

Draft
joelteply wants to merge 17 commits into
fable/chunk-depthfrom
fable/readiness
Draft

joelteply wants to merge 17 commits into
fable/chunk-depthfrom
fable/readiness

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

A swap is a pointer now (310 swaps at 0.113 ms each in four live turns on the M5, 2026-11-28 03:27Z, against ~20 ms a
token, 900 of 908 tokens on a kept graph), so when the lane can switch to a mind depends on whether she is ready: her
KV hot, her genes attached, her new tail rendered, her graph built. Each is its own preparation, running in parallel
with the Core's step, as her parts run in parallel in her mind (THE-WHOLE-MIND.md §3).

continuum_sage::readiness::Readiness is the one parent, a SAGE Component that does what every preparation shares:
it watches the lane's Horizon (who may step soon, with her slack), keeps each mind's state (Ready, Preparing with an
estimate, Refused), works the most pressed mind first one unit at a time (each unit its own input, so a newer horizon
is heard between units), measures what a unit costs (seconds per unit of the leaf's own measure: bytes, tokens,
nodes) to say when each mind will be ready behind those ahead of her, lets go of minds who left the horizon, gives
everything back at rest and says so, and publishes one Table the lane reads. A leaf implements Readies: what a mind
needs from it now, how much is left, how one unit advances, how to let her go.

Design: THE-LANE-ON-SAGE.md, "Readiness: the parts that get the next mind ready", and its slice in the order (two
leaves of opposite shape next: the genes stager on its own worker, the graph warmer in the Core's GPU wait; then the
lane's switch-in read from readiness).

Tests (continuum-sage, readiness): the most pressed mind is made ready first; a mind who leaves the horizon is let go
and no longer named; a ready mind is prepared again once what it prepared changed, with a measured estimate.
sage 107/107; ratchets green.

Stacked on #6302. Serves the path's step 1 (fast): with swaps near free, the lane's switch is bounded by preparation; this is the base the four preparations (pager, genes stager, renderer, graph warmer) share.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…the Core

A swap is a pointer now (310 swaps at 0.113 ms each in four live turns on the M5, 2026-11-28 03:27Z, against ~20 ms a
token, 900 of 908 tokens on a kept graph), so when the lane can switch to a mind depends on whether she is ready: her
KV hot, her genes attached, her new tail rendered, her graph built. Each is its own preparation, running in parallel
with the Core's step, as her parts run in parallel in her mind (THE-WHOLE-MIND.md §3).

continuum_sage::readiness::Readiness<R> is the one parent, a SAGE Component that does what every preparation shares:
it watches the lane's Horizon (who may step soon, with her slack), keeps each mind's state (Ready, Preparing with an
estimate, Refused), works the most pressed mind first one unit at a time (each unit its own input, so a newer horizon
is heard between units), measures what a unit costs (seconds per unit of the leaf's own measure: bytes, tokens,
nodes) to say when each mind will be ready behind those ahead of her, lets go of minds who left the horizon, gives
everything back at rest and says so, and publishes one Table the lane reads. A leaf implements Readies: what a mind
needs from it now, how much is left, how one unit advances, how to let her go.

Design: THE-LANE-ON-SAGE.md, "Readiness: the parts that get the next mind ready", and its slice in the order (two
leaves of opposite shape next: the genes stager on its own worker, the graph warmer in the Core's GPU wait; then the
lane's switch-in read from readiness).

Tests (continuum-sage, readiness): the most pressed mind is made ready first; a mind who leaves the horizon is let go
and no longer named; a ready mind is prepared again once what it prepared changed, with a measured estimate.
sage 107/107; ratchets green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… five files (pure moves)

driver.rs held the frame loop's entry and every verb of the Driver, at 999 lines: no change to it could land (the
1,000-line rule), and the readiness work needs the lane to publish its horizon from here. Its impl moves out by
concern, each its own file:

  driver/intake.rs  what reaches the frame loop: take, admit, suspend, preserve (161 lines)
  driver/step.rs    one step: resume, checkpoints, a prefill chunk, a decoded token (215)
  driver/facts.rs   what a turn reports: its facts and its probe row (52)
  driver/switch.rs  who is on the Core: bind, retire, her record, her footprint (94)
  driver/turn.rs    a turn in flight and where its time went (71)

driver.rs keeps the start (run, Start, context, the root resume), the errors, the Driver itself and the unit types
(435 lines). Moves only: the methods became pub(super) so the files reach each other, Turn's and Spent's fields
pub(super), and paths to the scheduler module one level deeper. Removed: an orphaned doc line whose function was
deleted earlier. persona_scheduler tests 30/30 before and after; ratchets green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@github-actions github-actions Bot added size: XL and removed size: L labels Nov 28, 2026
joelteply and others added 15 commits November 27, 2026 22:35
…t the next mind ready"

The block layer's Streamer (unwired) carried its own copy of what Readiness now owns: a forecast of who steps next,
soonest first, one move at a time, measured move times, a published table. It becomes the pager, a Readies leaf that
says only what a mind's block needs (her bytes, when it is not on her consumer's tier), how a move starts through its
pair's link, and how a fence lands it; its Demand, Placements and its copy of the mechanism are deleted.

The parent gains what the pager needs and every device-backed leaf will: a unit may start and land later
(Advanced::Started, its end delivered as one of the leaf's acts), one unit of a part in flight at a time, measured
from start to landing, and a leaf's own inputs (Readies::Act: the pager's Hold and Landed), after each of which every
mind not being prepared is asked again (how a block held again mid-move gets its own move).

Tests: the Streamer's two invariants kept as the pager's (one DMA at a time, the most pressed mind first, nothing
started behind an unlanded move, her landing starting the next, a measured estimate for the next mind; a block held
again mid-move never takes the old move's landing), awaiting the link's start events, never polling. blocks 8/8
(the same count), sage 107/107, ratchets green. UNIFIED-PAGING.md's Streamer section is now the pager's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…d decodes them together (S6, slice 1)

Live is GPU-bound (a 10 s sample 2026-11-28 03:30Z: the scheduler thread 95% waiting on the GPU), and one engine step
for several minds reads the weights once for all of them. Measured on the M5 (Qwen3.6-35B-A3B Q4_K_M, Q4_0 K/V, FA,
each mind at 8k, core stopped): llama-batched-bench at 04:37Z, one mind 66.6 tok/s, two 97.0, four 139.0; and
through our own tier (the persona_batch example, four minds each bound by her attached storage, 64 teacher-forced
tokens) at 04:47Z: time-shared 67.1 tok/s aggregate, batched 141.6 (2.11x), each mind 35.4 tok/s against 16.8,
every mind's argmax the same in both arms (0 of 64 differ).

- UnifiedTier holds a stream per sequence its context has (sized from the context, the STREAMS constant deleted)
  and decodes several bound minds in one step: submit_batch, each her tokens at her positions on her own stream,
  refused by name when they wear different genes (adapters are per context). A single mind's step is a batch of
  one, so there is one decode path.
- How many minds the Core binds at once has one owner, persona_scheduler::STREAMS, read by the context the driver
  makes (n_ctx is a whole window per stream: a window never shrinks to seat more) and by the pool the node fits. It
  is one until the driver executes the lane's Batch (slice 2), then admission's measured answer.
- THE-LANE-ON-SAGE.md open question 1 answered with these receipts.

Live is unchanged by this slice (one stream). persona_scheduler 30/30, persona-llama checks with examples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…with her (S6, slice 2a)

The engine had one active mind by construction, so a batch had nowhere to hold the minds it decodes. Roles gains the
minds bound beside the active one, each in her own stream, who decode only inside a batch step with her:

- bind_beside: her copy-in through the tier like a staged mind's, and her place beside only once it landed (the
  unified tier's attached bind is a pointer, landed when it returns); a mind already here is handed back by name.
- swap_active: the active mind and one beside her trade places, no transfer; refused while a step is on the device.
- unbind_beside: she leaves through the one copy-out path a retired mind takes, given back by finish_retirement.
- Execute::submit_batch and PersonaEngine::submit_batch: one step for several bound minds, in flight like any other,
  so one step is still in flight at a time; a mind not bound is refused by name and nothing is submitted. The
  unified tier's single step and its batch are one decode (decode_steps).

Tests (persona-engine, the Core's contract): a batch decodes the bound minds in one step and nothing goes in behind
it; a mind beside leaves through the one copy-out and is given back; the active mind and one beside her trade places
without a transfer and a mind bound once is not bound again. persona-engine 24/24 (21 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… one engine step (S6, slice 2b)

The lane could choose Batch, and the driver stepped only the running mind for it. Now:

- The envelope admits Batch only for minds that decode (a batch is one decode step, so a mind still prefilling is
  never in one), as many as the streams beside the running mind hold (batch_width is the streams the Core binds).
- pick returns one turn or a batch, the batch's turns in a buffer the lane owns and refills (no allocation a pick).
- step_batch: the active mind leads; each mate decoding under her genes is bound beside her (from the parked minds,
  when a stream is free) and decoded with her in one submit; each mind's end checks and her sample are the single
  step's own (decode_token split into before_decode and after_decode), from her own output of the one decode, and
  each step is booked by the single step's account (extracted from step). Ended turns leave by descending index.
- A mind bound beside is switched to by a role swap, no transfer (promoted when nobody is active, as at a stop); a
  finished one-off beside leaves through the one copy-out, or a probe says she keeps her stream.
- The step's kind is an enum (Moved: a decode, a prefill from a position, nothing), not two flags.

Live is unchanged: persona_scheduler::STREAMS is one, so a batch is never admissible. Slice 2c decides the streams
from the pool fit (the most minds whose whole windows fit). persona_scheduler 30/30, persona-engine 24/24,
sage 107/107, ratchets green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…by the pool fit (S6, slice 2c)

How many minds the Core binds at once was a constant (one). It is now serving's fit, carried to the scheduler:

- Rooms::whole_window_streams: the most minds, up to the roster, whose whole trained windows all fit every room read
  (another stream only for another whole window, never a divided one: 2026-11-21's halved context stays
  impossible); one when not even two fit, or no room was read to say so. With more than one, the pool's demand is
  that many whole windows.
- The count rides ServingTarget::lanes to EngineLaunch::streams, the adapter, GenerationAllocation::streams and
  SchedulerConfig::streams (n_ctx = streams x window); the lane's batch is as wide (batch_up_to). STREAMS is deleted;
  a context outside the Core states its one stream where it is built.
- Each turn's row counts her tokens decoded in a batch step (persona.engine.turn batched=).

Note for the M5: several streams view no attached storage (persona_by_pointer is one stream), so minds bound into
them move by row copy (bound beside, a mind stays bound while she decodes); minds preserved as attached files come
back cold once. Option B (per-stream attention, pointer-bound files) removes both.

Tests: host_fit 6/6 (the_core_holds_another_stream_only_for_another_whole_window), stream_layout, serving_daemon
157/157, engine 60/60 in the touched modules; ratchets green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…witch binds beside while a stream is free

Live on the M5 at 05:33Z (3fbfdb8, four whole-window streams): not one token batched (batched=0 on every turn),
and decode slower (25-29 ms a token against 23) since a switch now copied minds in and out. Two causes:

- The envelope forced a switch to a waiter at her bound, leaving the running mind waiting, and the learned policy
  counts an untried batch's uncertainty against the wait bound, so it never tried one. A waiter at her bound who
  decodes is now served by a batch with the running mind and the other decoding waiters, the most pressed first, as
  many as the streams beside her hold (batch_with; never a mind still prefilling; a switch on a one-stream Core as
  before). Once batches run, the policy learns their outcome like any action's.
- switch_to retired the occupant and staged the next mind. While a stream is free beside the occupant, the next
  mind is bound there and swapped in, and the occupant stays bound; with none free, the occupant moves out as before.

Tests: a_crowd_at_the_bound_is_served_by_one_batch_when_the_streams_hold_it (four streams, three, one; a prefilling
waiter is switched to); sage 108/108, persona_scheduler 30/30, ratchets green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ab69b)

switch_to takes the next mind out of the parked minds before the occupant moves out; a refused retirement, or a
retirement it could not finish, returned early and dropped her unit. Both exits park her again first. The driver has
no harness without a real model (it holds a live context); a fake-tier driver harness is carded to make it testable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ed ones; a Windows-true routing binding

Live on the M5, 06:06-06:21Z (Codex, 8aab69b): four streams, 27 turns, 11,588 tokens, none batched, 23.47 ms a
token. With decoding minds beside the running one, the learned policy kept continuing or switching between them: it
had never tried a batch, and counts an untried action's uncertainty against the wait bound.

- One batch step serves the running mind and every member at about one step's cost (the M5: four minds 67.1 to
  141.6 tok/s aggregate; the 5090, Codex 06:17Z: 160.0 to 435.8, 2.72x, 1 of 64 argmax differing), so continuing
  her alone or switching to a member is dominated and no longer offered beside it; a switch to a mind the batch
  cannot hold (prefilling, or past its width) stays the policy's. Test: a_batch_replaces_the_continue_and_switches_it_dominates;
  the envelope's earlier admission test states the new set; its record-ring check runs on one stream.
- Rooms::whole_window_streams returns the streams and the window each holds: the footprint's verified window where
  it sits below the trained one (Codex: demand at the trained window against a fit capped at the verified one never
  qualified a second stream), used for the demand, the fit and the window alike; a footprint with no KV a token
  prices no second stream. Tests: zero KV, no footprint, workspace without windows, a verified window below trained.
- RoutingCaptureRefused::Unknown carries sys::llama_routing_capture, the generated type on every target (u32 on Unix,
  i32 on Windows; Codex, the 5090 build).

sage 109/109, serving_daemon 157/157, persona_scheduler 30/30, ratchets green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…rve ubatch

Three whole-window streams aborted the core 77 times from 06:32Z (decode -> sched_reserve -> graph_reserve rounds
2048 to 2049 -> llama-lived-routing.cpp:120). Fork test-graph-slots reproduces it without the fix and passes with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…sen; record the fork pin

Live on the M5 (06:06-06:21Z and 06:49-06:54Z) no turn batched, and the lane's decisions left no trace: whether
the envelope never offered a batch, or offered one the policy passed over, could not be read. The Decider exposes
the last envelope's admissible actions; the lane books on the running mind's turn each decision that offered her a
batch and each that chose one; persona.engine.turn carries batch_offered and batch_chosen beside batched.

core/vendor/LLAMA_CPP_PIN records d91a0fc14, the pointer 46d6066 moved to without it (the vendor_pin ratchet
caught it; that commit was pushed without the ratchets run, mine).

sage 109/109, persona_scheduler 30/30, ratchets 135/135.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…mind under others is switched to

Live on the M5 (07:23Z, a7d08e3): a resident's turn chose a batch 85 times (42 on another) and batched no token.
Each resident wears her own genes (genes=3 at every generation) and a step applies one gene set, so the driver
dropped every mate and stepped the running mind alone. Worse, a waiter at her bound was "served" by a forced
batch she could not join, and waited on.

The lane's Mind carries `genes`, the gene set's identity (continuum_persona_llama::genes_key, beside same_genes:
each adapter by pointer, with its scale; a collision can only cost a batch, since same_genes is still checked).
The envelope's batch and batch_with take only minds under the running mind's genes; a pressed mind under others is
switched to; with none sharing her genes, no batch is offered and continuing is again.
Test: a_batch_holds_only_minds_wearing_the_running_minds_genes. sage 110/110, persona_scheduler 30/30, ratchets green.

Batching minds under different genes needs adapters applied per sequence within one step (carded).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…enes (per-sequence adapters), for review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…er different genes

THE-LANE-ON-SAGE.md, open question 1, "Across genes" (built; Codex approved the design 07:53Z). Live on the M5 a
resident's turn chose a batch 85 times and batched nothing: every resident wears her own genes and a step applied
one set, so 4145651 gated batches to minds under the running mind's genes. The fork now applies an adapter set
per sequence (llama.cpp #172, pinned 0d2e3d981), and the gate is deleted.

- core/llama `seq_genes.rs`: name_seq_genes / clear_seq_genes / seq_genes_gathered, refusals typed.
- The tier (`unified_tier/genes.rs`): a stream names the genes of the mind bound there when she first steps under a
  set it does not wear, and gives them up at her move_out. The context-wide apply in decode_steps and its
  same-genes refusal are gone. A lesson's attach returns her stream to the context's set, so her lesson runs on the
  base and the shadow as before; minds served beside it keep their genes, where before a serving step during a
  lesson replaced the shadow.
- Stream order: with a stream per mind the engine takes a ubatch's sequences only as consecutive increasing ids and
  splits a step out of that order (measured in #172: such phases reused 0 graphs). The tier pushes a step's rows in
  stream order and maps the caller's token indices for logits_ith and sample (RowOrder, allocated once).
- Deleted: the lane's Mind.genes and both gates on it, genes_key, the exported same_genes, the driver batch's
  same-genes check, and the test that pinned the gate.
- persona_batch takes adapters: mind i wears the (i mod n)-th.

## Measured (the M5, 2026-11-28 13:46Z, Qwen3.6-35B-A3B Q4_K_M, the live core sharing the GPU)
persona_batch, 4 minds at 2k, 64 teacher-forced tokens, each under a different resident's own gene (Aris and Atlas
code_owner, Aiko and Benchy speech-discipline): time-shared 32.8 tok/s aggregate, batched 64.0 (1.95x), 0 argmax
disagreements of 64 for every mind. No genes, same conditions: 36.9 -> 69.3 (1.88x).
Sage 109/109 (one test deleted with the gate), persona_scheduler 30/30. Fork side: test-seq-adapters (#172).
Live window after deploy: owner Fable, today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…s; only its own adapter's free refuses it

Codex's two blockers on llama.cpp #172, fixed there: past inp_out_ids a group adds to its own output rows (before,
the token-space rows were the wrong rows there, and the CPU's get_rows aborted), and an adapter is named by its
address and a per-load serial, so a free of an unrelated adapter neither refuses a named set nor rebuilds a graph
(before, any free on the model refused every named set until named again: genes page in and out live).

## Measured (the M5, 2026-11-28 14:00Z, Qwen3.6-35B-A3B Q4_K_M, the live core sharing the GPU)
persona_batch, 4 minds at 2k under four residents' own genes (Aris, Atlas, Aiko, Benchy), on this pin: time-shared
68.3 tok/s, batched 147.7 (2.16x); again 67.7 -> 144.4 (2.13x); 0 argmax disagreements of 64 for every mind. Two
runs at 13:59Z, while the core was busier, ran out of GPU memory in the first decode (Metal
kIOGPUCommandBufferCallbackErrorOutOfMemory); the no-gene control a minute later ran (39.9 -> 153.8).
Fork side: test-seq-adapters on #172.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…raph instead of aborting; a parked mind's freed gene refuses only her

The M5 restart-looped on 86af36c (82 aborts at llama-lived-routing.cpp:120 beside a lesson): the capture was
sized for the ubatch, and a re-reserved scheduler beside a lesson built past it. Fork: capture sized by one owner
and grown before a larger graph; refuses() checks only the batch's sequences; the node budget follows worn genes.
Reproduced and fixed in test-graph-slots (the assert exactly before, exit 0 after).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
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