Skip to content

A page switch never stalls the other minds' decode: dyno 11b, the kv_page probe reads the engine's copy and IO apart, engine pin to fork #118 - #6002

Open
joelteply wants to merge 4 commits into
canaryfrom
fable/async-page-streaming
Open

joelteply wants to merge 4 commits into
canaryfrom
fable/async-page-streaming

Conversation

@joelteply

@joelteply joelteply commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

How this serves the minds: a mind's page save or restore no longer freezes every other resident's decode, and two minds returning at once each wait only for their own page. This is path step 1, "Fast", and order-of-work line 3b (one live engine, its minds' memory moved by us; graphics-engine model: async resource streaming, where the render thread never blocks on IO).

Measured (the problem)

The pinned fork runs every KV page save and restore, disk IO included, as one task on its single task loop (tools/server/server-queue.cpp:138-153; save at server-context.cpp ~2809/2960, restore ~2996/3076 on cd2e16d87). Receipt: two restores the core issued together on the M5 at 2026-11-14 00:18:13Z. Benchy waited 1,024 ms, which is exactly Aris's 1,012 ms restore in the engine (fixtures/dyno/2026-11-13-restart.json engine_page_lanes).

Dyno 11b (core/continuum-engine/src/capacity/dyno/restart/stall.rs): before and after

The rates come from the restart day's receipts (save 603,433 B/ms, restore 1,464,377 B/ms, 32,273 B/token). The host copy rate is new: 40,558,095 B/ms, a memcpy measured on this M5 (Apple M5 Pro) at 2026-11-14T07:24:45Z while it served. The engine's copy_ms receipt replaces it after deploy.

Scenario On the loop (pinned fork) Streamed (fork #118)
Four residents' saves at once: other slots' decode stall 13,547 ms 204 ms
Four saves: last receipt 13,547 ms 5,021 ms
Aris and Benchy restores together: Benchy's receipt 1,917 ms 1,026 ms
Those two restores: other slots' decode stall 1,917 ms 70 ms

Assumption, not measured: concurrent streams each keep their measured single-stream disk rate. The per-stream rates are 0.6 to 1.5 GB/s, under the SSD's, but the aggregate is unmeasured, and io_ms on the live node settles it.

Change

  • Dyno 11b: switches_at_once(&[Switch], PageIo::{OnTheLoop, Streamed}), plus three tests. Four saves stall decode for their copies, not their writes. Two restores issued together each wait only for their own read. No receipt arrives before its own IO. The fixture gains host_copy_bytes_per_ms with its receipt.
  • Probe: inference.kv_page.action reads the engine's receipt through one owner, page_receipt::EngineWork. That replaces the three inline field reads in turn_admission.rs, and engine_fields is now private to it. The probe adds copy_ms (the engine loop's share, which is what other slots wait for) and io_ms (its IO worker's). Both read "none" from an older engine. One pinned test covers this.
  • Pin: core/vendor/llama.cpp and core/vendor/LLAMA_CPP_PIN move together to the merge of server: a KV page's file IO runs on a worker; the task loop only copies the state in or out llama.cpp#118 on codex/s4-per-mind-integration. The HTTP contract and the page files are unchanged, so pages on disk still restore. A restore whose slot was given another task while it read now gets a typed 400 ("refusal": "slot_reassigned"). The core already treats it as Terminal::Rejected, which leads to a cold prefill, and the occupant's KV is kept.

Follow-up: the page IO byte budget (owner: Fable, with #6011's owner)

Fork #118 now admits every in-flight page switch's host bytes against one runtime budget (POST /page-io/budget, GET /page-io). Until the core sets it, it is 0, meaning one switch at a time: still off the engine loop, but the overlap that dyno 11b predicts for saves needs room. The owner of the live host room (#6011, live_pool) sets it as one more holder of that room. The probe already reports admit_ms and io_bytes_in_flight.

Follow-up: the stage contract (owner: Fable)

Page save/restore completion moves onto the minimal stage contract once it merges (branch fable/prefill-during-the-tool: RuntimeModule with typed produces and ArtifactSelector subscriptions). A page's completion becomes an artifact that other stages (admission, the prefill stage) subscribe to, with no per-feature channel. This PR deliberately keeps the core change to the probes and the pin.

Measured after deploy (open)

The check is inference.kv_page.action copy_ms/io_ms on the M5, plus the decode of resident slots during a stop checkpoint and a restore pair. Owner: Fable, due on the first deploy carrying this pin.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…de; the kv_page probe reads the engine's copy and IO apart

The pinned fork runs a page save or restore, disk IO included, as one task on its single
task loop: every other slot's decode waits for it, and switches issued together wait for
each other (the M5 2026-11-14 00:18:13Z: Benchy's restore waited 1,024 ms behind Aris's
1,012 ms). Dyno 11b models the switch on the loop vs streamed (the loop copies the state
in or out, the files move on a worker), from the restart day's receipts plus the M5's
host memcpy (40,558,095 B/ms, measured 2026-11-14T07:24:45Z):

- four residents' saves at once: decode stall 13,547 ms -> 204 ms; last receipt
  13,547 ms -> 5,021 ms
- the Aris/Benchy restore pair: Benchy's receipt 1,917 ms -> 1,026 ms; decode stall
  1,917 ms -> 70 ms

The kv_page.action probe reads the engine's receipt through one owner (EngineWork, in
page_receipt.rs) and adds copy_ms (the engine loop's share, what other slots wait for)
and io_ms (its IO worker's), "none" from an engine without them (fork PR #118).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply and others added 3 commits November 14, 2026 01:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…bytes_in_flight (fork #118 review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… with the in-flight byte budget

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