Skip to content

continuum-flow: Stage + capacity dispatcher + calibrated simulator (FLOW plan step 1) - #5561

Closed
joelteply wants to merge 5 commits into
canaryfrom
fable/continuum-flow
Closed

joelteply wants to merge 5 commits into
canaryfrom
fable/continuum-flow

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Step 1 of FLOW-IMPLEMENTATION-PLAN (#5560). This PR is the floor primitive and its simulator; nothing is wired to it yet.

  • Stage: CBAR's QueueThread in Rust.
  • Scheduler: a pure state machine covering QoS classes, a serial queue per owner, supersede that keeps the newest, a background shed bound, aging up to Work, yields matched to outranking waiters, and the next aging instant as its only timer.
  • Flow: an event-driven dispatcher whose grant is released by drop.
  • sim: calibrated to the M5's measurements (2026-10-28).

16 tests pass, run locally in a serving-down window on the M5. The simulator reproduces the live gate removal (simulated 76 -> 57 s; live 122 -> 84 s). On a full engine, a directed reply's first token comes in 1.7 s, and a dream completes 16 times an hour at 4% cost to work.

Simulator finding: a fourth usable slot barely helps (57 -> 56 s). Throughput per act is bound by context size, so the next lever is work per act, not scheduling.

🤖 Generated with Claude Code

joelteply and others added 3 commits October 28, 2026 09:07
… event-driven dispatcher per capacity (draft, untested)

SERVING-ENGINE §1c. Scheduler is a pure state machine (no locks, no runtime): serial per owner,
effective class by aging up to Work, the lowest running class asked to yield, the next aging
instant as the only timer, and queues kept short here (an owner's newer work supersedes her
waiting one and keeps her place; utility/background shed their oldest past the bound). Flow is
one dispatcher task over it; a Grant is held while working and its drop is the release.
Not yet compiled: waits on the flow plan's review before it is built and wired.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…d a simulator calibrated to the M5; 16 cases green

- Stage: a bounded keep-newest input, one worker task woken only by a push, a class.
- Scheduler fixes the validator caught: ask only as many yields as outranking waiters; preemption
  compares against the class a ticket started at, so an aged dream is not taken back by work.
- sim: decode 30.5*n^0.865 tok/s across n streams (101 at four), prefill 304/sqrt(n) per job, page-out
  0.1 s (M5, 2026-10-28). Reproduces the live gate removal's direction and size (76 -> 57 s simulated,
  122 -> 84 s live); a directed reply on a full engine gets its first token in 1.7 s; a dream runs
  16 times an hour and slows six residents by 4%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…backpressure, never drops) or KeepNewest for signals only

Codex on the FLOW plan (6d18b45): committed inputs and tool results must never ride a dropping
queue. Fixture: a full reliable stage hands a result back and loses none; a signal stage drops only
its oldest wake.

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

Copy link
Copy Markdown
Contributor Author

Source review at e9730fa (Cormac), read for step 4 (training and the examiner on the flow), which builds on this. Read: lib.rs, qos.rs, scheduler.rs whole. #5567's stage fix is reviewed separately (PASS).

Right, and what step 4 relies on:

  • The background share is real. A waiting background ticket ages one class per step up to Work and then wins ties on age (b.since.cmp(&a.since)), so under permanent Work saturation it takes the next freed slot after two aging steps. That is the measured minimum share Flow implementation plan: the concurrent-mind doctrine against 160 measured gates (docs only) #5560 asks for, without a second mechanism.
  • Aged work never preempts. Yields compare the waiting ticket's RAW class with the running ticket's started_as, so a dream that aged into its slot is not taken back by Work, and aged work never forces a yield.
  • One timer, no polling: next_wakeup is the dispatcher's only clock.

One thing to settle before step 4 can use this (blocking for training, your call for this PR): submit sheds the oldest waiting Utility/Background ticket past capacity. For a droppable signal that is right. A training job is durable work. Shed, its owner has to resubmit it, and a resubmit starts a new since, which resets its aging. Under steady load a training job can be shed and resubmitted indefinitely without ever aging into its turn: exactly the starvation §2.8 rules out. The flow needs the reliable/droppable distinction the Stage layer already has (Overflow) at the scheduler too: a reliable ticket is never shed and keeps its since, and only a droppable one is bounded. Either submit(.., overflow: Overflow), or reliable work submitted through a path that never sheds. Codex raised the same typed reliable-vs-droppable point on #5560.

A contract note for step 4, no change needed here: owners are serial queues, so a training job must NOT share its persona's owner key. Kimi's training would otherwise hold her own acts for its whole run. In step 4 I will key training by job (or by a (persona, Training) owner), so her acts and her training are two queues.

Not run: no tests run locally; CI and your simulator cases are the receipts. Once the shedding contract is decided, I write the training consumer against this interface.

…uts (#5567)

* fix(flow): publish producer closure before waking stage

* test(ci): classify flow as an independent workspace leaf
@joelteply

Copy link
Copy Markdown
Contributor Author

Landed through #5567 (which carried the whole continuum-flow crate and Cormac's PASS at ac93cf9). Closing in the 10-29 sweep.

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