Repository navigation
DeepSeek V4.1 on Metal: --prefill-from pulls a prompt's prefix state and lands it in the served lane - #96
Closed
BlivionIaG wants to merge 1 commit into
Closed
DeepSeek V4.1 on Metal: --prefill-from pulls a prompt's prefix state and lands it in the served lane#96BlivionIaG wants to merge 1 commit into
BlivionIaG wants to merge 1 commit into
Conversation
…and lands it in the served lane With --prefill-from URL (and --mcdma-link NAME, or --mcdma-link http) the served lane asks a producer to prefill the prompt's prefix, pulls the MKVH protocol-2 hand-off over the link or plain HTTP, and lands it in a blank Snapshot (model_import, Snapshot.snapshotBlank/Seal); the pass then plans from where the landed prefix ends (a mark at the prefix, the tail run locally) and the model stays resident while a request waits for its fill. The landed prefix is labelled remote and never kept as native. A hand-off file is read in 1 GiB steps, since one read of 2 GiB or more fails on macOS. The start-up line no longer says the lanes are greedy only. Not included: per-prompt routing, the breaker, TF_PREFILL_TAIL, several links.
This was referenced Nov 16, 2026
Owner
Author
|
Published upstream as a draft instead: ashhart#3594. |
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.
What this changes
Before, a Metal DeepSeek-V4.1 server serves every prompt itself. After,
--prefill-from URL(with--mcdma-link NAME, or--mcdma-link http) makes the served lane ask a producer to prefill the prompt's prefix, pull the MKVH protocol 2 hand-off over the link or plain HTTP and land it in a blank Snapshot (model_import,Snapshot.snapshotBlank/Seal). The pass then plans from where the landed prefix ends (a mark at the prefix, the tail run locally), and the model stays resident while a request waits for its fill. The landed prefix is labelled remote and never kept as native. A hand-off file is read in 1 GiB steps, since one read of 2 GiB or more fails on macOS. The start-up line no longer says the lanes are greedy only. Not in this slice: per-prompt routing, the breaker,TF_PREFILL_TAIL, several links. Slice 6 of the chain in ashhart#3553 (the first on the Mac side).mixed/m0-lane-base(7fa5f1b747): the merge of the CUDA/library stack (upstream deepseek_v41 handoff: CUDA record codecs, FP4 packers and the part plan ashhart/TensorFold#3563 to deepseek_v41 CUDA: a split KV pool is exported by shard, each rank exporting its own ashhart/TensorFold#3567, head9b2b616b8c) with DeepSeek-V4.1-Flash on Metal: the EXL3 2.9 bpw lane ashhart/TensorFold#2373 (headbec140d545, its commits and authors untouched). It adds no behavior; the conflicts incli.zig,prompt_cache.zig,lane_stream.zig,metal_dsv41_limits.zigandruntime_sources/dsv41.zigare resolved on main's side with DeepSeek-V4.1-Flash on Metal: the EXL3 2.9 bpw lane ashhart/TensorFold#2373's changes re-applied. Not proposed upstream until the maintainers' EXL3 series is visible: DeepSeek-V4.1-Flash on Metal: the EXL3 2.9 bpw lane ashhart/TensorFold#2373 is being replaced, and at its headzig build compile-dsv41-token-mapfails on any host (reported there). This PR adds one commit:f77151495e.atc overlap --json: not run: this PR is on the fork. It runs when the slice is opened upstream.Checks on this head
f77151495epython3 tools/zig/lean_check.py, on the parent head and on this head: 339 problems on the parent head, 339 on this head, 0 new (tools/zig/lean_new.py).zig build -Dfixed-cpu test-native --summary all: 170 pass, 0 fail, 3 skip (63 steps).zig build -Dfixed-cpu test-dsv41-handoff --summary all: 93 pass†.zig build -Dfixed-cpu test-lane-api-host --summary all: 689 pass†.zig build -Dfixed-cpu test-dsv41-env-host test-environment-host --summary all: 14 and 23 pass†.zig build -Dfixed-cpu test-dsv41-draft --summary all: 139 pass†.zig build -Dfixed-cpu test-handoff-routes-host test-metal-launch-map-host --summary all: 24 and 5 pass†.compile-dsv41-server: exit 0†.zig fmt --check build.zig zigandgit diff --check: clean.tools/pr_check.py --base <parent>: 0 errors, advisory warnings only (--pr, and a documentation example address0.0.0.0where listed).zig build test test-golden(full suite),dev-tools,test-exl3-gpuandtest-deepseek-v41on this head, any Metal run of this slice on its own. † counts were measured on the tree before a test-only fix tozig/src/native/qwen27_handoff_test.zig; those steps do not compile that file. The failing-before check for the new tests was not done.Receipt
tools/bench_concurrent.py --alone --serial, 64 tokens,--context 32768 --parallel 4 --prompt-cache-gib 0,TF_DSV41_PREFILL_STEP=4096, compared withtools/bench_exl3_compare.pyfrom the DeepSeek-V4.1 EXL3 Metal follow-up to #2373: exact tiled decode, fused chains, prefill chunking, last-row and Sinkhorn fixes ashhart/TensorFold#3382 line): token-equal in every cell, short prompts at 1 and 4 streams and temperatures 0 and 1.0 (6 cells) and long prompts at 1 and 4 streams (2 cells). Decode 40.6 to 40.5 tok/s at one stream and 43.5 to 43.5 aggregate at 4; the long prompt's TTFT 12.19 to 12.15 s at one stream. Same run, mixed-mode flags given but the producer prefers local (auto): token-equal too.mixed/m7-guidebefore a test-only fix, with the CUDA stack at9b2b616b8c; two GB10 (TP=2), one M5 Ultra,--prompt-cache-gib 0, cold unique prompts, median of 2 to 3,TF_DSV41_PREFILL_STEP=4096,TF_PREFILL_ROUTE=alwayson the Mac): TTFT with the Mac alone against mixed mode: 2k 2.37 s against 2.04 s (below the pull threshold in both, so the difference is run-to-run), 8k 7.35 s against 3.74 s, 32k 29.9 s against 12.5 s. 14 prompts were pulled (6,974 to 29,296 tokens) and none failed. Decode is the Mac's in both: 39.2 tok/s at one stream, 51.0 against 52.5 aggregate at 4 streams. Exact answers of 40: 40 and 40. 64k was not measured: the harness skipped it at a 70,000-token context.--prefill-frompointing at a closed port, and at an unreachable network,TF_PREFILL_ROUTE=always): the prompt is prefilled on the Mac after the failed attempt, replies are token-equal to DeepSeek-V4.1-Flash on Metal: the EXL3 2.9 bpw lane ashhart/TensorFold#2373's parent in every cell, the breaker opens after three failures and the server logs that the pair does not answer/health. The first-token wait cost was 0.3 s at one stream (12.19 to 12.5 s). A producer that accepts the connection and then hangs was not tried: both failures returned at once.--prefill-from; nothing changes without it [INFERENCE from the flag gate; the flags-off run above is the check].--prefill-from URLand--mcdma-link NAME|http, both off by default;TF_PREFILL_API_KEY_FILE,TF_PREFILL_TIMEOUT_S(Prefill on a GB10, decode on a Mac: long prompts for Qwen3.8-27B handed over ConnectX (#1594, step 2b) ashhart/TensorFold#2648's),TF_DSV41_HANDOFF_FILE(a diagnostic read withstd.c.getenv, listed indocs/environment.md).9b2b616b8c, Zig 0.17.0, Metal on an M5 Ultra and CUDA on two GB10, the EXL3 2.9 bpw pack. Paths and platforms: Metal arm64 and the GB10 producer ran; HTTP link and the M-series other than M5 did not.Checklist