Skip to content

A change of adapter set rebuilds the graph, never re-reserves the scheduler - #169

Open
joelteply wants to merge 1 commit into
fable/lived-routingfrom
fable/adapter-switch
Open

joelteply wants to merge 1 commit into
fable/lived-routingfrom
fable/adapter-switch

Conversation

@joelteply

Copy link
Copy Markdown

set_adapters_lora marked the scheduler for a full re-reserve on every change of set: drain the GPU, drop
every cached graph, create a new scheduler, reserve the worst-case graphs. Residents with and without
genes alternate every few tokens on one context, so each switch paid it. The allocator already grows its
buffers when a graph needs more (ggml_backend_sched_alloc_splits), so a change of set only needs the
graph rebuilt; the scheduler is re-reserved only when the set's nodes could exceed the budget it was
reserved for (sched_max_nodes, recorded at reserve).

Measured on the M5, Metal, idle GPU, Qwen3.6-35B-A3B Q4_K_M, the serving shape (n_ubatch 2048, flash
attention, Q4_0 K/V), single-token decodes at 512 (test-walk-exact WALK_ADAPTER_SWITCH_BENCH, the set
changing between none and one adapter every token, twice each):
before: 14.08 / 14.05 ms/token fixed, 20.56 / 20.66 alternating (a change: 6.6 ms)
after: 14.06 / 13.98 ms/token fixed, 15.77 / 15.76 alternating (a change: 1.8 ms, the rebuild)
Found by profiling the M5's live core (sample, 20 s while residents decoded): of 2,498 samples in llama_decode, ~570 were sched_reserve and 974 opt_alloc_graph, while the driver waited for the GPU ~70% of the time.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…eduler

set_adapters_lora marked the scheduler for a full re-reserve on every change of set: drain the GPU, drop
every cached graph, create a new scheduler, reserve the worst-case graphs. Residents with and without
genes alternate every few tokens on one context, so each switch paid it. The allocator already grows its
buffers when a graph needs more (ggml_backend_sched_alloc_splits), so a change of set only needs the
graph rebuilt; the scheduler is re-reserved only when the set's nodes could exceed the budget it was
reserved for (sched_max_nodes, recorded at reserve).

Measured on the M5, Metal, idle GPU, Qwen3.6-35B-A3B Q4_K_M, the serving shape (n_ubatch 2048, flash
attention, Q4_0 K/V), single-token decodes at 512 (test-walk-exact WALK_ADAPTER_SWITCH_BENCH, the set
changing between none and one adapter every token, twice each):
  before: 14.08 / 14.05 ms/token fixed, 20.56 / 20.66 alternating (a change: 6.6 ms)
  after:  14.06 / 13.98 ms/token fixed, 15.77 / 15.76 alternating (a change: 1.8 ms, the rebuild)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/adapter-switch branch from 27030ed to 35dd70c Compare November 28, 2026 02:09
@joelteply
joelteply changed the base branch from fable/context-memory-rows to fable/lived-routing November 28, 2026 02:09
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