Skip to content

dsv41 metal: the server's idle ticker keeps the model wired between requests - #3384

Merged
ashhart merged 7 commits into
mainfrom
lead/dsv41-keep-warm
Nov 15, 2026
Merged

ashhart merged 7 commits into
mainfrom
lead/dsv41-keep-warm

Conversation

@ashhart

@ashhart ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner

DeepSeek-V4.1 on Metal: the server's idle ticker now keeps the model wired between requests.

The problem. The Metal backend gave the lane host no keepalive target, so the server never started its idle ticker for this family. macOS unwired the ~300 GiB of weights a second or two after each request, and the next request had to re-wire all of it before its first token. On an M5 Ultra, vm_stat showed 6 GiB wired between requests and 305 GiB within 2 s of a request starting. Even a cached follow-up with a few new tokens took 1-2.5 s to its first token.

The change. The backend passes the weights' residency owner's keepalive target to the lane host, the same target the other Metal families use. The target's buffers already join that set (#3321). The ticks commit on a plain queue of their own, so the ticker's thread never commits on the family's queue mid-round. How long the ticker runs after the last request is the server's --keep-warm (default 900 s).

Measured on an M5 Ultra on the release checkpoint, with this change on a build of the queued DeepSeek PRs:

  • Wired memory between requests: 6 GiB before, 305.5 GiB after, steady 20+ s after a request.
  • First request after a restart: 1.8 s to first token before, 0.28 s after.
  • Cached follow-up after 15 s idle: 1-2.5 s before, 0.016 s after.

Tests: new served test (j). A model with a residency owner gives the server a ticker whose ticks run before and after a request; a model without one gives none. test-dsv41-metal-serve passes. Lean finds nothing new.

Stacked on #3326 (and its #3321). The drafter's own residency set (#3296) joins the same tick when the decode stack is rebased over this.

  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the lead/dsv41-keep-warm branch 2 times, most recently from e955d89 to 6045819 Compare November 15, 2026 11:18
…ame launch

TF_DSV41_TREE=2..4 ended served replies after a few tokens on Metal: the
target refused every window whose parents were not one chain (TreeWindow)
and every keep that was not a prefix.

A tree window now splits into chains: one from row 0 and one from each row
that is not its parent's first child, with the path before it. Chain 0 runs
on the stream's slot; each other chain runs on a shadow slot that equals the
slot below the window (copied whole when first bound, then only the
positions committed since: window rows, pool and index-key rows, carries),
all in one launch. A row run again in front of a branch must choose as on
its own chain. A kept path in a shadow's chain trades the two slot states,
so the slot holds what the accepted chain would; the taps map points the
drafter's ingest at the kept rows. Shadows are made on the first tree window.

serve_lanes.Model gains `trees` so tests set the knobs without the
environment. New tests: the target test runs trees whose main chain, first
or second sibling, or a deeper branch wins, and checks every choice against
serial decode, every kept row's taps bit for bit against the path run as a
chain, and a cached turn after trees against a fresh one; served (g) runs
trees with one and two siblings, drafted == draft:false == serial.
…; kept branches copy into the slot

Review of #3326: the target held one tree state, so two streams' tree windows in one window call
(draft/lanes.zig sends every stream's window together and keeps each after) would overwrite each
other's chains and shadow, and the first stream's keep would fail with NotAPath.

Each slot now has its own tree window (Tree.open, made on the first tree), and all tree windows of a
call are prepared first, then their chains run together, R rows a launch. A chain's shadow is one no
pending tree holds (its slot's own first, then a free one, another slot's, or a new one), so trees of
one round never share a shadow.

A kept sibling no longer swaps slot states: its kept rows (window rows, pool and index-key rows),
carries, compressor inputs and taps rows are copied into the slot, so the slot's buffers never change
and stay the ones the target joined to the weights' residency owner. A new shadow joins that owner
when the target did (Resident.tryAddNow, refused past its load limit) and leaves it before it is freed.

Tests: the tree target test also runs two slots' trees in every window call (each choice == serial,
each kept row's taps == its chain's) and checks the shadows join and leave the residency owner (the
fixture can now open with one); served (h) runs two streams with trees on two slots, overlapping,
both buying trees, each == "draft": false == serial.
…urn and before a thinking prompt's <think>

A thinking prompt ends in <|Assistant|><think>, and the next turn renders that turn as <|Assistant|></think>..., so the
whole-prompt entry was never a prefix of a follow-up and every thinking turn read the whole conversation again. A new
conversation sharing the system prompt and tools found nothing either. Prefill now runs the prompt in up to three parts
and keeps a state at each cut (before the first <|User|> once the system part is 256 tokens or more, and before the final
<think>); the resume path is the one cached prompts already take.
Metal's served model fixed its calibration knobs to the built-in table, so a cost table measured on the serving
machine could not be used. It now passes TF_DSV41_CALIB_FILE through when set (the cached path that already reads
such a file); unset, the built-in table as before.
…t's buffers wired between requests

The Metal backend gave the lane host no keepalive target, so the server never ran its idle ticker for this family:
macOS unwired the ~300 GiB a second or two after each request and the next request re-wired all of it first (1-2 s
on an M5 Ultra; vm_stat showed 6 GiB wired idle and 305 GiB within 2 s of a request starting). The backend now passes
the weights' residency owner's target (the target's buffers joined it), ticking on a plain queue of its own so the
ticker's thread never commits on the family's queue mid-round. Served test (j): a model with a residency owner gives
the server a ticker whose ticks run before and after a request; one without gives none.
@ashhart
ashhart force-pushed the lead/dsv41-keep-warm branch from 6045819 to 0250587 Compare November 15, 2026 11:45
@ashhart
ashhart merged commit 3a56d4e into main Nov 15, 2026
2 of 10 checks passed
@ashhart
ashhart deleted the lead/dsv41-keep-warm branch November 15, 2026 11:45
ashhart added a commit that referenced this pull request Nov 17, 2026
Seven duplicate entries go (a PR's own line beside its lines-file line), five outside authors are thanked, #1503 gets the line its close note promised, and eleven lines now match their PRs' code and receipts (#3129, #3194, #3258, #2696, #2921, #3365, #3345, #3384, #3679, #3682, #3699, #3393).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant