Repository navigation
DeepSeek-V4.1 on Metal: the target's buffers stay resident in their own set - #3321
Merged
Merged
Conversation
This was referenced Nov 14, 2026
The prompt scratch and buffers, each slot's KV regions, tail and taps, the forward buffers, the layer scratch and the RoPE tables were in no residency set, so macOS could unmap them between command buffers and map them again when the next one was submitted. Target.init now holds them in one residency set on the engine's queue (requested resident at once), and deinit removes it before the buffers go.
…ide its load limit Review (D894): the target's own residency set bypassed the 70% wired budget the weights' Resident enforces. The target now hands its buffers to that owner (Resident.tryAddNow), which refuses and logs a join past its limit, and removes them from it before they are freed; boot passes the owner through serve.Parts.
ashhart
force-pushed
the
lead/dsv41-target-resident
branch
from
November 15, 2026 11:14
b4a23a7 to
3ab639d
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.
DeepSeek-V4.1 on Metal: the target's own buffers were in no residency set. That covers the prompt scratch and buffers, each slot's KV regions, tails and taps, the forward buffers, the layer scratch and the RoPE tables. Only the weights (and, with #3296, the DSpark drafter) were held. macOS could unmap them between command buffers and map them again when the next one was submitted. With the GPU idle, a prompt chunk or the decoder pass then waited 50-830 ms between commit and its first GPU instruction, and a fresh server's first request waited about 1.9 s.
Target.initnow puts them in one residency set on the engine's queue, requested resident at once.deinitremoves it before the buffers go. No kernel or arithmetic changes, so replies are unchanged.Measured on an M5 Ultra (512 GB), release weights, cold prompts over repo docs (a fresh nonce each), a fresh server per arm, arms alternated A B A B. Both arms carry #3318 (the Engram overlap) and a timing log of commit to GPU start:
Commit to GPU start, for a buffer committed with the GPU idle: without the set 20-833 ms (sum over a 32K prompt 1.25-2.4 s); with it 0.7-4.5 ms. The first request after load: 1,935 / 1,734 ms without, 5.5 / 6.1 ms with.
The 16-prompt decode bench (greedy, seeded sampled,
"draft": false): 48/48 reply hashes equal main's; decode tok/s unchanged on main's decode path.One run with the decode bench first still showed 45-157 ms waits at some 32K chunks. Something else unmapped after decoding is still outside a set; not chased here.
zig build test-dsv41-metalpasses on an M5 Max (1,135 checks). Lean: 0 new.Synthena (Ash's Agent)