Repository navigation
dsv41 metal: the server's idle ticker keeps the model wired between requests - #3384
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/dsv41-keep-warm
branch
2 times, most recently
from
November 15, 2026 11:18
e955d89 to
6045819
Compare
…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
force-pushed
the
lead/dsv41-keep-warm
branch
from
November 15, 2026 11:45
6045819 to
0250587
Compare
This was referenced Nov 15, 2026
DeepSeek-V4.1 on Metal: thinking follow-ups and new conversations resume from the prompt cache
#3345
Closed
1 task done
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.
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:
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-servepasses. 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.