Repository navigation
Conversation
…ind's slot orders its inputs by its own events A context has one output buffer and reads it only after synchronize(), which waits for everything queued, so a caller serving several minds could not queue mind B's step before reading mind A's. With the output ring on (llama_set_output_ring), each decode takes the spare buffer by pointer swap before reserving its outputs and records an event once its output copies are queued; a ticket (llama_output_ticket) reads that decode's logits after waiting on its event alone (llama_ticket_logits). Off by default. Queuing was still serialized one level down: a scheduler of one copy has no events, so every split input from the CPU (the token embedding) waited for the Metal backend to drain, A's step included. ggml_backend_sched_use_events gives such a scheduler events, so each input waits for this scheduler's own last use of its backend; graph slots use it, a slot's last use being that mind's previous step. Measured on the M5 (Qwen3.6-35B-A3B Q4_K_M, Q4_0 K/V, FA, core stopped, 03:24-03:27Z), test-output-ring: two minds, each her own stream and graph slot, one token each in turn, 192 steps, serial against pipelined (B queued before A is read): minds at 1.2k/1.9k: 14.07 / 14.05 -> 13.56 / 13.60 ms/step (96-97%); again 14.17 -> 13.52 (95%), submit 1.35 ms minds at 30k/30.7k: 18.34 -> 17.89 ms/step (98%), submit 1.45 ms logits bit-identical at every step (max |diff| 0) Without the scheduler events the pipelined arm was slower than serial (contended: 27.05 -> 30.11 ms/step). The live core is GPU-bound now (a 10 s sample at 03:30Z: the persona-scheduler thread 95% in settle, 5% in submit), so this plumbing's value is what it enables (a decode read by ticket, inputs ordered by events: batched decode), not the 2-5% it saves alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
force-pushed
the
fable/output-ring
branch
from
November 28, 2026 06:45
3b8d682 to
0c2b2bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A context has one output buffer and reads it only after synchronize(), which waits for everything queued, so a
caller serving several minds could not queue mind B's step before reading mind A's. With the output ring on
(llama_set_output_ring), each decode takes the spare buffer by pointer swap before reserving its outputs and records
an event once its output copies are queued; a ticket (llama_output_ticket) reads that decode's logits after waiting
on its event alone (llama_ticket_logits). Off by default.
Queuing was still serialized one level down: a scheduler of one copy has no events, so every split input from the
CPU (the token embedding) waited for the Metal backend to drain, A's step included. ggml_backend_sched_use_events
gives such a scheduler events, so each input waits for this scheduler's own last use of its backend; graph slots
use it, a slot's last use being that mind's previous step.
Measured on the M5 (Qwen3.6-35B-A3B Q4_K_M, Q4_0 K/V, FA, core stopped, 03:24-03:27Z), test-output-ring: two minds,
each her own stream and graph slot, one token each in turn, 192 steps, serial against pipelined (B queued before A
is read):
minds at 1.2k/1.9k: 14.07 / 14.05 -> 13.56 / 13.60 ms/step (96-97%); again 14.17 -> 13.52 (95%), submit 1.35 ms
minds at 30k/30.7k: 18.34 -> 17.89 ms/step (98%), submit 1.45 ms
logits bit-identical at every step (max |diff| 0)
Without the scheduler events the pipelined arm was slower than serial (contended: 27.05 -> 30.11 ms/step).
The live core is GPU-bound now (a 10 s sample at 03:30Z: the persona-scheduler thread 95% in settle, 5% in submit),
so this plumbing's value is what it enables (a decode read by ticket, inputs ordered by events: batched decode),
not the 2-5% it saves alone.
Stacked on #170. Validator:
test-output-ring -m <model> -ngl 99(OUTPUT_RING_DEPTH sets the first mind's depth); fails on any logit difference.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo