Skip to content

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
mixed/m0-lane-basefrom
mixed/m1-prefill-from
Closed

BlivionIaG wants to merge 1 commit into
mixed/m0-lane-basefrom
mixed/m1-prefill-from

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

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).

Checks on this head

  • Head commit: f77151495e
  • Lean checker, python3 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).
  • Tests run, with the command and pass, fail and skip counts:
    • 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 zig and git diff --check: clean. tools/pr_check.py --base <parent>: 0 errors, advisory warnings only (--pr, and a documentation example address 0.0.0.0 where listed).
  • CI: none on the fork.
  • Not run, and why: zig build test test-golden (full suite), dev-tools, test-exl3-gpu and test-deepseek-v41 on this head, any Metal run of this slice on its own. † counts were measured on the tree before a test-only fix to zig/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

  • Main against branch: there is no main to compare on the Mac side: the Metal DeepSeek-V4.1 lane is DeepSeek-V4.1-Flash on Metal: the EXL3 2.9 bpw lane ashhart/TensorFold#2373's. Flags-off against DeepSeek-V4.1-Flash on Metal: the EXL3 2.9 bpw lane ashhart/TensorFold#2373's parent receipts, taken earlier on the same M5 (tools/bench_concurrent.py --alone --serial, 64 tokens, --context 32768 --parallel 4 --prompt-cache-gib 0, TF_DSV41_PREFILL_STEP=4096, compared with tools/bench_exl3_compare.py from 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.
  • Whole-stack run (this tier's tip, mixed/m7-guide before a test-only fix, with the CUDA stack at 9b2b616b8c; 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=always on 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.
  • Fallback with the producer unreachable (--prefill-from pointing 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.
  • Boxes it reaches: DeepSeek-V4.1 EXL3 on Metal with --prefill-from; nothing changes without it [INFERENCE from the flag gate; the flags-off run above is the check].
  • New switch? --prefill-from URL and --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 with std.c.getenv, listed in docs/environment.md).
  • Environment: this tier's tip and the CUDA stack at 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.
  • Licence of any new weights or drafter: n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

…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.
@BlivionIaG

Copy link
Copy Markdown
Owner Author

Published upstream as a draft instead: ashhart#3594.

@BlivionIaG BlivionIaG closed this Nov 16, 2026
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