Repository navigation
dsv41 metal: exact cold prompts faster (Engram reads beside the first rows, bigger row cache, busy keepalive probe) - #3459
Merged
Merged
Conversation
Owner
Author
|
Final-head check done (head 66ae970, base #3360 ab9c2ee, M5 Ultra, two rounds alternating):
The description's table now carries these. Ready to land after #3360.
|
1 task done
ashhart
force-pushed
the
lead/dsv41-prompt-short
branch
2 times, most recently
from
November 21, 2026 13:43
da31522 to
cf361ce
Compare
ashhart
force-pushed
the
lead/dsv41-prompt-short
branch
from
November 21, 2026 20:46
cf361ce to
8afbc9c
Compare
…tched to 64 rows tf_attn_lo and tf_attn_hi widen through the bfloat type (the same values), so the decode kernel's dots and sums spend fewer instructions a key; the prompt kernel's own widening copy goes. With that, loading each step's keys a step ahead wins at every row count measured, so decode launches take the prefetch pipeline up to 64 rows. A 72-row decode shape keeps the plain pipeline under the contract. Bits equal main's.
… origin, the first commit, the decoder's time and late buffer starts
…atches settled outside the readers' lock
…ows, the first run's rows read first The chunk's Engram row ids are hashed once for every layer. Before the first commit only the first run's layer-1 rows are queued; the second run's and layer 14's queue behind them once the GPU has layer 0. The first run (30% of the chunk's rows, chunks of 512 rows or more) goes through layers 1-13 as soon as its rows are in, the second as a later chunk would, from its first row's keys; layer 14 on runs all rows. Prompt tests compare chunks of 900 rows in two runs of 270, 9 and 450 rows, chunks of 64 in runs of 19 and 45, and every cold chunk in the prompt-then-decode check, against one run and against decode: 0 values differ.
At 65536 records a prompt's reads (more than a quarter of the cache) were read through, never kept. At 4M a 4096-row chunk's batches are kept, and the rows of common n-grams stay cached across requests.
The target gave the server's ticker only its idle tick. With the busy probe (as the Qwen3.8-27B server has) a tiny command buffer on the ticker's own queue uses the weights' set every interval of a request, under the owner's hold, so macOS keeps the layers a long prompt is not using wired. The served keepalive test runs the probe beside its ticks.
Main's stepped path starts the profile clock and times the decoder cone, so its first-commit and decoder rows are right.
No change in behavior. Keeps prompt.zig within the 600-line cap with main's image rows and staged chunks.
ashhart
force-pushed
the
lead/dsv41-prompt-short
branch
from
November 21, 2026 23:35
8afbc9c to
ca427d9
Compare
This was referenced Nov 22, 2026
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: faster cold prompts on the exact path (prompt bits equal decode bits): 2K 868 → 909 tok/s, 8K 1,112 → 1,310, 32K 1,224 → 1,491.
What was slow (exact path, cold, M5 Ultra;
TF_DSV41_PROMPT_PROF, extended in 1b8855f with per-Engram-layer rows, waits and late command-buffer starts):Changes:
Exactness. Chunks split in two runs match one run and decode with 0 differences: 900-row chunks split 270/9/450, 64-row chunks 19/45, and the prompt-then-decode check with every chunk in two runs. The Engram cache and keepalive change no math. No new kernels.
Measured on an M5 Ultra (cold prompts):
The 32K row came from builds with the same code as this head (the head adds only an issue-order fix). On the exact head (66ae970 vs #3360's ab9c2ee, two rounds alternating head and base, cold prompts):
Decode on the exact head: 48/48 replies equal to base (16 prompts, 512 tokens; greedy, sampled and
"draft": false), drafted greedy =="draft": falseon 16/16, speed unchanged (greedy 73.6 vs 73.7, sampled 60.5 vs 60.6, plain 46.4 vs 46.3 tok/s).Checks: test-dsv41-shared, env-host, test-dsv41-metal and test-dsv41-metal-serve pass (the served keepalive test runs the probe). Lean finds nothing new.
What's left: at 2K the exact path's GPU time alone is ~2.34 s, so it tops out near 945 tok/s. Dense FP8 projections are ~42% of each layer. The exact tensor-unit trick used for the experts doesn't carry over, because the dense FP8 weights span a median 10 bits within a group.
Stacked on #3360.