Skip to content

The M5 lane uses the GPU matrix units, never falls back to the CPU, places its draft, and one mind's results ring stops flipping its prefix - #5209

Merged
joelteply merged 7 commits into
canaryfrom
fable/m5-tensor-api
Oct 20, 2026
Merged

joelteply merged 7 commits into
canaryfrom
fable/m5-tensor-api

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

DEPLOYED on the M5 since 10-19 15:31Z as e678bb3; this PR lands it so the running code exists on canary. Cards 9b9f3b59, 3c9fda87.

  • Metal lanes set GGML_METAL_TENSOR_ENABLE (our engine build makes the M5/A19 tensor API opt-in), decided in the Metal arm of the backend verdict. Validated on the 27B in a side process (correct output, no exception; the fork had made it opt-in in May over an in-process FFI exception risk).
  • A hung --list-devices probe REFUSES a GPU lane instead of appending --n-gpu-layers 0 (a 27B lane silently served on the CPU). constrain_to_cpu and BackendVerdict::ProbeHung deleted.
  • --spec-draft-ngl is told, never left to the engine's auto fit.
  • Results ring: every result is perceived from every workspace, labelled with its own (one workspace_label owner); the in-flight action is excluded by sequence, not root; evicted_pointer_scopes (write-only) deleted. Restored KV pages read cold (cached 0 of 24,670 / 29,999) because the ring appeared and vanished with the root (fix(cognition): preserve workspace scope in retained result projection #5108).

Measured (M5 Pro, Qwen3.8-27B, live)

  • Same binary, interleaved, 5,490-token prompt: prefill 1,163/1,153 tok/s without the tensor API vs 2,185/1,478 with.
  • Live, before (14:22-15:22Z, d900060) vs after (16:33-17:33Z, e678bb3): prefill median 105 -> 175 tok/s; reuse 39% -> 48% (27% the first hour after relaunch: cold cache); page restores 2 warm / 0 cold.
  • source-hygiene 37/37 at the rebased head.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 7 commits October 19, 2026 18:54
…it size the window let it grow to

The M5, 2026-10-18 22:15-22:42Z: four residents on ONE slot (13% reuse, 600 s lane waits, 12-25
min acts) while the plan wanted two lanes: Allocator { served: 1, window: 48,661, lane_cap: 2 }.
The need was the median post-fit size of held turns; the flexbox grows every prompt into the
window it is given, so on a 102k lane the need read ~48.6k and a second lane at ~46k was refused.
The need tracked the window, and the window the need.

window_allocator::turn_need sums the turn's budget claims' FLOORS (framing + tools, required
input, grounding floor, her last move and its outcome, the reply floor): what she cannot do
without. The allocator still grows each lane toward the wish; it now serves two lanes when memory
holds two windows above that floor (Joel: two residents per lane, never smaller windows to seat
more). The faculty calls it once and nets -1 line.

Tests: window_allocator, llm_deliberation_faculty and working_set suites: 158 passed, 0 failed
(M5, background QoS).

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

The reply floor is clamped to what this window leaves after framing and required input; summing the
clamped value under-reports her reply exactly when the lane is too small, so the allocator would
believe the small window suffices (IntelMac's 32k lanes). The need now adds the pre-clamp floor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…d, and collapse goes all at once

Measured on the M5 (prompt captures, 104 consecutive act pairs, six residents, 2026-10-18): in
46% of the re-prefilled characters the first changed byte was a ring result rewritten to its
pointer, or back. fit_messages collapsed oldest-first until the history fit this act's budget,
which swings with the newest result's size: a result collapsed on one act came back whole on
the next, and the frontier crept through the middle of the ring, re-prefilling all behind it.

Now a collapsed result stays collapsed while it is in the ring (per-resident set, pruned to the
pointers offered), and a forced collapse takes every collapsible result in one rewrite, so the
acts after it append. Bodies stay reachable by handle. The test that pinned re-expansion as a
'projection' now pins the sticky rule, then clears the set to keep its refit check intact.

Tests: llm_deliberation_faculty + working_memory 142 passed, 0 failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…on/ring_collapse.rs (Cormac on #5175)

StickyCollapse::apply holds the rule and its receipt; fit_messages keeps one call. The faculty file
nets -1 line (the ratchet). Unit test in ring_collapse.rs pins all-at-once, sticky across a roomy act,
a new result riding whole at the frontier, and the set pruned to what the ring offers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… to the CPU, places its draft, and one mind's results ring stops flipping its prefix

- Metal lanes set GGML_METAL_TENSOR_ENABLE (our engine build makes the tensor API
  opt-in), decided in the Metal arm of the backend verdict. Measured M5 Pro 10-19,
  same binary and 5,490-token prompt, interleaved: prefill 1,163/1,153 -> 2,185/1,478
  tok/s, identical output. Fusion / graph-optimize: no gain, left off.
- A hung --list-devices probe REFUSES a GPU lane instead of appending
  --n-gpu-layers 0 (a 27B lane served on the CPU at ~130 tok/s prefill, 5.7 decode).
  constrain_to_cpu and BackendVerdict::ProbeHung are deleted.
- --spec-draft-ngl is told, never left to the engine's auto fit.
- Results ring: every result is perceived from every workspace, labelled with its
  own (one workspace_label owner for body, pointer and evicted pointer); the in-flight
  action is excluded by sequence, not root. Restored KV pages read cold (cached 0 of
  24,670 / 29,999) because the ring appeared and vanished with the root (#5108).
  evicted_pointer_scopes deleted (write-only after this change).
- file_size baseline 158,255 -> 158,240.

Cards 9b9f3b59, 3c9fda87.

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

Copy link
Copy Markdown
Contributor Author

Codex review of the requested GPU-placement claim at 0c62b8f: PASS, conditional on exact-head CI.

Verified: ProbeHung and constrain_to_cpu are absent from the launch/receipt/argument owners. The remaining --n-gpu-layers emission in lane_args uses cpu_only, which the production launch supplies from target.placement == LanePlacement::Cpu. Missing device evidence returns Refused, and that verdict returns a Spawn error before launching; it cannot append a CPU override. Explicit CpuByPlan still works. I compiled this exact head's standalone backend_receipt module with rustc --test on Windows: 5/5 passed, including missing GPU evidence refusal and the explicit CPU positive control.

This supersedes my local unpushed 11443cd7e patch for the same seam; I will not open a competing PR. It also fixes the stale timeout diagnostic my patch had missed.

Scope: this is the requested backend-placement review, not independent verification of the M5 measurements, results-ring changes, or matrix-unit execution. The Metal flag and draft placement describe requested configuration; full EngineConfig capability/adoption evidence remains a separate owned task. Core and Windows CI are still running at review time.

@joelteply
joelteply merged commit 3fdc2e3 into canary Oct 20, 2026
9 checks passed
@joelteply
joelteply deleted the fable/m5-tensor-api branch October 20, 2026 00:36
joelteply added a commit that referenced this pull request Oct 20, 2026
Every act re-rendered the user-side prompt from ~15 sources and chased
byte-stability between renders. On the M5 (2026-10-19,
delib.prompt.reuse_split) every act diverged where the results ring,
mid-prompt, grew by one result, re-prefilling 17-29k tokens per act;
replaying those captures through continuum-context's Epoch reused 92-95%.

cognition/epoch_view.rs (new, the one owner): the faculty renders its
sources as keyed blocks (each turn, each ring result / banner / collapsed
index, each trailing contribution, each standing grounding piece); the
view appends only what is new or changed since the last act, and the
request carries the epoch. A turn that joins a run appends alone; a saved
result collapsed to its pointer at turnover never re-expands; what a fit
dropped never comes back. Facts, the clock and the required tail still
render fresh after the body every act (parrot-loop order kept).

Turnover (Epoch::turn_over, retiring sources the act no longer offers)
happens only when the window's budget says the epoch no longer fits
(the existing flex allocation's msg_budget), or on another activity room. Each turnover is a context.epoch.turnover probe with
reason, superseded_chars and epoch_chars; each act a context.epoch.append
probe. A view renders on a copy; only a request the model answered becomes
her epoch, so a refused, refitted or failed request leaves it as it was.

fit_messages now frees at least one drop chunk past the minimum (and the
pointer substitution stops a chunk under the budget): the room a new epoch
grows into. An exact fit turned over on every act in the new test.

Deleted as superseded: ring_collapse.rs (StickyCollapse, #5209: its only job
was keeping collapsed pointers byte-stable between re-renders), the trailing-grounding stable_prefix_order sorts
(render_trailing, GroundingPlan::trailing_messages), the ring/grounding
order history comments (flipped four times for byte-stability), the
results_ring_renders_before_churning_grounding test, the per-act
front-stability half of the quantum test, the dead messages_within;
stable_prefix_order stays for the system message only. Working memory's
ring now names each message's part (RingPart).

Tests: epoch_view (4), consecutive_acts_send_the_last_acts_body_as_their_
prefix and the_window_turns_the_epoch_over_and_the_next_act_extends_it
through contribute(), a_turnover_fit_frees_a_chunk_on_whole_messages.
llm_deliberation_faculty.rs 12,681 -> 12,596 lines; BASELINE_LINES_OVER
157,618 -> 157,526.

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 Oct 20, 2026
Every act re-rendered the user-side prompt from ~15 sources and chased
byte-stability between renders. On the M5 (2026-10-19,
delib.prompt.reuse_split) every act diverged where the results ring,
mid-prompt, grew by one result, re-prefilling 17-29k tokens per act;
replaying those captures through continuum-context's Epoch reused 92-95%.

cognition/epoch_view.rs (new, the one owner): the faculty renders its
sources as keyed blocks (each turn, each ring result / banner / collapsed
index, each trailing contribution, each standing grounding piece); the
view appends only what is new or changed since the last act, and the
request carries the epoch. A turn that joins a run appends alone; a saved
result collapsed to its pointer at turnover never re-expands; what a fit
dropped never comes back. Facts, the clock and the required tail still
render fresh after the body every act (parrot-loop order kept).

Turnover (Epoch::turn_over, retiring sources the act no longer offers)
happens only when the window's budget says the epoch no longer fits
(the existing flex allocation's msg_budget), or on another activity room. Each turnover is a context.epoch.turnover probe with
reason, superseded_chars and epoch_chars; each act a context.epoch.append
probe. A view renders on a copy; only a request the model answered becomes
her epoch, so a refused, refitted or failed request leaves it as it was.

fit_messages now frees at least one drop chunk past the minimum (and the
pointer substitution stops a chunk under the budget): the room a new epoch
grows into. An exact fit turned over on every act in the new test.

Deleted as superseded: ring_collapse.rs (StickyCollapse, #5209: its only job
was keeping collapsed pointers byte-stable between re-renders), the trailing-grounding stable_prefix_order sorts
(render_trailing, GroundingPlan::trailing_messages), the ring/grounding
order history comments (flipped four times for byte-stability), the
results_ring_renders_before_churning_grounding test, the per-act
front-stability half of the quantum test, the dead messages_within;
stable_prefix_order stays for the system message only. Working memory's
ring now names each message's part (RingPart).

Tests: epoch_view (4), consecutive_acts_send_the_last_acts_body_as_their_
prefix and the_window_turns_the_epoch_over_and_the_next_act_extends_it
through contribute(), a_turnover_fit_frees_a_chunk_on_whole_messages.
llm_deliberation_faculty.rs 12,681 -> 12,596 lines; BASELINE_LINES_OVER
157,618 -> 157,526.

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 Oct 20, 2026
Every act re-rendered the user-side prompt from ~15 sources and chased
byte-stability between renders. On the M5 (2026-10-19,
delib.prompt.reuse_split) every act diverged where the results ring,
mid-prompt, grew by one result, re-prefilling 17-29k tokens per act;
replaying those captures through continuum-context's Epoch reused 92-95%.

cognition/epoch_view.rs (new, the one owner): the faculty renders its
sources as keyed blocks (each turn, each ring result / banner / collapsed
index, each trailing contribution, each standing grounding piece); the
view appends only what is new or changed since the last act, and the
request carries the epoch. A turn that joins a run appends alone; a saved
result collapsed to its pointer at turnover never re-expands; what a fit
dropped never comes back. Facts, the clock and the required tail still
render fresh after the body every act (parrot-loop order kept).

Turnover (Epoch::turn_over, retiring sources the act no longer offers)
happens only when the window's budget says the epoch no longer fits
(the existing flex allocation's msg_budget), or on another activity room. Each turnover is a context.epoch.turnover probe with
reason, superseded_chars and epoch_chars; each act a context.epoch.append
probe. A view renders on a copy; only a request the model answered becomes
her epoch, so a refused, refitted or failed request leaves it as it was.

fit_messages now frees at least one drop chunk past the minimum (and the
pointer substitution stops a chunk under the budget): the room a new epoch
grows into. An exact fit turned over on every act in the new test.

Deleted as superseded: ring_collapse.rs (StickyCollapse, #5209: its only job
was keeping collapsed pointers byte-stable between re-renders), the trailing-grounding stable_prefix_order sorts
(render_trailing, GroundingPlan::trailing_messages), the ring/grounding
order history comments (flipped four times for byte-stability), the
results_ring_renders_before_churning_grounding test, the per-act
front-stability half of the quantum test, the dead messages_within;
stable_prefix_order stays for the system message only. Working memory's
ring now names each message's part (RingPart).

Tests: epoch_view (4), consecutive_acts_send_the_last_acts_body_as_their_
prefix and the_window_turns_the_epoch_over_and_the_next_act_extends_it
through contribute(), a_turnover_fit_frees_a_chunk_on_whole_messages.
llm_deliberation_faculty.rs 12,681 -> 12,596 lines; BASELINE_LINES_OVER
157,618 -> 157,526.

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 Oct 22, 2026
Canary (#5209) already carries the budget-floor need; the code moved to prompt/view.rs.
Keep only what canary lacks: find the reply claim by its id, not claims[4] (Cormac on #5177).

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