Repository navigation
Conversation
joelteply
force-pushed
the
fable/adapter-switch
branch
from
November 28, 2026 02:09
27030ed to
35dd70c
Compare
joelteply
force-pushed
the
fable/graph-slots
branch
2 times, most recently
from
November 28, 2026 02:15
64acdfe to
c6f751b
Compare
… another mind
A backend scheduler holds the split and allocation of one graph, so a context serving several minds one step at a
time rebuilt, re-split and re-allocated its graph at every switch: on the M5 live (Qwen3.6-35B-A3B, four residents)
0 of 74 steps in a turn reused a graph, with 78 switches. The Core binds every mind into its one sequence, so
nothing visible to the engine told one mind's step from another's.
A graph slot is a second scheduler with its own graph results. Entering one swaps the context's scheduler, graph
results, active graph and adapter set with the slot's (four pointer swaps), so every use of the context's scheduler
is unchanged; decode() swaps back when it returns. Slots serve ubatches of one token per sequence only; prefill and
training stay on the context's worst-case scheduler.
Each mind's steps keep their graph in her own slot, keyed by whom the ubatch's sequences serve: the owner names her
when it binds her (llama_set_graph_slot_key; an unnamed sequence is keyed by its id). Whether her kept graph serves
the step is the graph's own reuse check (K/V extent, adapter set, pin and every other input), never a key derived
here; when it cannot (her K/V crossed a 256-cell block, her genes changed), she rebuilds in her own slot and no other
mind's graph is touched. A slot keeps the adapter set object its graph was built with, so that check (which compares
the set by pointer) holds when she returns; a slot made before any adapter free is dropped, since a freed address
may come back (llama_model::lora_frees). The owner sets how many slots from the minds it keeps resident
(llama_set_graph_slots; 0, the default, keeps none).
Measured on the M5 (Qwen3.6-35B-A3B Q4_K_M, Q4_0 K/V, FA, routing capture on, core stopped so the GPU is quiet,
02:15Z), test-graph-slots: four minds round-robin one token each, three adapter sets, 192 steps:
the Core's shape (one stream, each mind bound by her attached storage, named by persona id):
no slots 16.57 ms/step, 0 reused; slots 14.31 ms/step, 188 of 188 possible reused
a stream each: no slots 16.34 ms/step, 0 reused; slots 14.67 ms/step, 188 reused
four slots hold 16.5 MiB; logits bit-identical at every step in both (max |diff| 0)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
force-pushed
the
fable/graph-slots
branch
from
November 28, 2026 02:19
c6f751b to
84b05f6
Compare
…erves graph_reserve rounds a ubatch up to a multiple of the sequences (three streams reserve 2049 of a 2048 ubatch); the routing capture held exactly n_layer x n_ubatch rows, so any re-reserve with the capture on aborted at its bound (the M5, 2026-11-28 06:32Z onward: 77 aborts, decode -> sched_reserve -> graph_reserve -> llama_route_experts, once the core held three whole-window streams). The capture now holds the rounded ubatch's rows. test-graph-slots: a three-stream context with the capture on, re-reserved by a setting changed after it, decodes; it aborted at llama-lived-routing.cpp:120 without the fix (checked), and passes with it; both graph-slot arms unchanged (max |logit diff| 0).
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 backend scheduler holds the split and allocation of one graph, so a context serving several minds one step at a
time rebuilt, re-split and re-allocated its graph at every switch: on the M5 live (Qwen3.6-35B-A3B, four residents)
0 of 74 steps in a turn reused a graph, with 78 switches. The Core binds every mind into its one sequence, so
nothing visible to the engine told one mind's step from another's.
A graph slot is a second scheduler with its own graph results. Entering one swaps the context's scheduler, graph
results, active graph and adapter set with the slot's (four pointer swaps), so every use of the context's scheduler
is unchanged; decode() swaps back when it returns. Slots serve ubatches of one token per sequence only; prefill and
training stay on the context's worst-case scheduler.
Each mind's steps keep their graph in her own slot, keyed by whom the ubatch's sequences serve: the owner names her
when it binds her (llama_set_graph_slot_key; an unnamed sequence is keyed by its id). Whether her kept graph serves
the step is the graph's own reuse check (K/V extent, adapter set, pin and every other input), never a key derived
here; when it cannot (her K/V crossed a 256-cell block, her genes changed), she rebuilds in her own slot and no other
mind's graph is touched. A slot keeps the adapter set object its graph was built with, so that check (which compares
the set by pointer) holds when she returns; a slot made before any adapter free is dropped, since a freed address
may come back (llama_model::lora_frees). The owner sets how many slots from the minds it keeps resident
(llama_set_graph_slots; 0, the default, keeps none).
Measured on the M5 (Qwen3.6-35B-A3B Q4_K_M, Q4_0 K/V, FA, routing capture on, core stopped so the GPU is quiet,
02:15Z), test-graph-slots: four minds round-robin one token each, three adapter sets, 192 steps:
the Core's shape (one stream, each mind bound by her attached storage, named by persona id):
no slots 16.57 ms/step, 0 reused; slots 14.31 ms/step, 188 of 188 possible reused
a stream each: no slots 16.34 ms/step, 0 reused; slots 14.67 ms/step, 188 reused
four slots hold 16.5 MiB; logits bit-identical at every step in both (max |diff| 0)
Stacked: #167 (merged) → #168 lived routing → #169 adapter switch → this. #169 and this were rebased onto #168 so the line is one; #168's
drop_reusable_graphsalso forgets the slots' graphs.Review asks (Codex): any path that holds the context's scheduler across a decode() return while a slot was active;
memory_update's forget fires on every real memory update (if paging makes that frequent, live graphs_reused shows it); the opt exclusions ingraph_slot_enter(labelled ubatch,opt_serving_continuation, a live reply's retained graph).Validator:
test-graph-slots -m <model> -ngl 99fails on any logit difference or any rebuild of a kept graph, in both shapes.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo