Skip to content

fix(server): DSML calls read from their own tags in the native server (the native side of #20) - #25

Merged
bertholomus merged 1 commit into
bertholomus:deepseek-v41-zigfrom
hashd1ve:dsv41-dsml-native
Oct 20, 2026
Merged

bertholomus merged 1 commit into
bertholomus:deepseek-v41-zigfrom
hashd1ve:dsv41-dsml-native

Conversation

@hashd1ve

Copy link
Copy Markdown

What this changes

The native server's side of #20 (222a9c0b on deepseek-v41-tp2).

  • DSML blocks first. DeepSeek-V4.1's DSML blocks are read from their own tags first, and the <tool_call> forms only in the text around them. Before, a <tool_call> in the prose with a </tool_call> in an argument dropped the block's calls.
  • Unoffered tools. A call to a tool the request did not offer is returned as a call, instead of being rewritten as <tool_call>{json}</tool_call> text.
  • Call streamer. The streamer only reads the text before the first DSML block. Before, a Qwen-style call quoted in a DSML argument (a file the model writes) streamed as a real call. tool_calls_streamed then kept the reply's own DSML calls from being sent.

Reported in bertholomus/deepseek-v4.1-tensorfold-tp2-2xgb10#29. This is unrelated to the malformed markup in #26 there.

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: deepseek-v41-zig at 9f82099 plus this change. Two DGX Sparks (GB10, 128 GB each), TP=2 over RoCE with both rails, nvcr.io/nvidia/pytorch:26.07-py3. Checkpoint easthambuilds/DeepSeek-V4.1-Flash-1017-EXL3-2.9bpw at 2913ea75. Served with --context 1048576 --parallel 4, drafts and CUDA graphs on.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: not run. Instead, 12 greedy chat prompts (temperature 0, 128 tokens, drafts on) give byte-identical text to the unpatched 9f82099 image, with this change and the two companion PRs built together.
  • Decode speed before and after, from tools/bench_openai.py: not run. The recipe's kit_bench.py decode --set a gives prose 57.0 → 56.9 and structured 104.9 → 104.3 tok/s, with the three PRs together.
  • Prompt speed before and after, from tools/prefill_cold.py: not run. No prompt-pass code changes.
  • Tests run, with pass, fail and skip counts: zig build test (CUDA host tests, aarch64 Linux) 219 pass, 0 fail, 0 skip, with the three PRs together.
  • Not run, and why: Metal (no Mac set up for this branch); the three tools above (we measured with the recipe's tools before we read this template).
  • For this change: tool calls 10/10 valid against a live server, as before. The updated unoffered-tool test and the new test fail on 9f82099 (2 failed) and pass with the change.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (not run as such; greedy replies equal the unpatched engine's)
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • Prompt processing is no slower than the last release. (not measured; server-side parsing only)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • 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. No AI attribution lines.

…<tool_call> text (the native side of bertholomus#20)

The native parser collected the <tool_call> forms and DeepSeek-V4.1's DSML blocks independently and kept whichever
started first. A <tool_call> in the prose before a block, with a </tool_call> in one of its arguments (a file being
written), swallowed the start of the block: the call was dropped and reached the client as text. A call to a tool the
request did not offer was rewritten as <tool_call>{json}</tool_call>, call syntax the model never wrote. And the call
streamer read the whole answer, so a Qwen-style <tool_call><function=NAME> quoted in a DSML argument streamed as a real
call to NAME when that tool was offered, and the reply's DSML calls were then never sent (tool_calls_streamed).

DSML blocks are now found first and the other forms only in the text around them; every invoke is a call, under the
model's own name when the request did not offer it (with one call a reply, such an invoke drops out as before); the
streamer is fed beforeDsml(answer), the text before the first DSML block. As 222a9c0 did for the Python server.

Tests: the unoffered-tool case now expects a call; a new test covers a <tool_call> in the prose, a </tool_call> and a
whole call in an argument, and calls in the reply's order. Both fail before this change.
@bertholomus

Copy link
Copy Markdown
Owner

Thank you @hashd1ve for this careful port of #20. The owner will decide on it.

@bertholomus

Copy link
Copy Markdown
Owner

Merged — thank you @hashd1ve! With this, the native Zig server reads DSML tool calls the same way the Python line does since #20, so both lines now give the same replies.

bertholomus added a commit that referenced this pull request Oct 24, 2026
…s it

A rank that stopped (an error, a crash, a kill) left the others waiting
inside their next exchange for good, their GPUs spinning on it: the
signature of tp2 #25's second hang. Each rank now watches its links
(link.Watch: a poll for the peer shutting its end, which frames never
set): when a peer rank goes and this process has not ended within 5 s,
it prints which rank went and exits 1. The server's rank 0 watches its
followers and the lane followers watch rank 0; rank 0's done, a follower
reading it and Model.close end the watch, so a clean shutdown is as
before. A follower that stops on an error also says why on stderr (its
stdout line stays for the gates).

Tests: a closed link is named and a frame on it is no close; a stopped
watch lets its links close quietly; the grace lets this process end
first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bertholomus added a commit that referenced this pull request Oct 24, 2026
…s too

A follower refuses a primitive expecting rank 0 to refuse the same one at
the same step. A GPU fault breaks that, as it is one rank's alone: in tp2
#25's second hang rank 1 hit CUDA_ERROR_ILLEGAL_ADDRESS at a launch,
printed follow_refused CudaFailed and stayed up, while rank 0 ran on into
its next exchange and waited there for good; rank 1's context ran nothing
more. Now a refusal on a CUDA failure asks the context (after a fault a
stream's query returns it for good). A failed context ends the follower at
once, without the orderly close (NCCL's teardown can wait on a peer): its
link closes, and the stopped-rank watch stops rank 0 with a line that
names this rank. A failed call the context survived, and every other
refusal, are as before.

Tests: a CUDA failure that left the context failed ends the follower; one
the context survived and other refusals do not, and others never ask.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bertholomus added a commit that referenced this pull request Oct 24, 2026
….7.1)

The README's fork note: v0.7.0's nine changes on the four-node branch's v0.3.1, then v0.7.1's seven (the shared DSML
reader and the streamed-prose fix with #25's tests, TF_DS_PROMPT_ALIAS, the stopped-rank watch, the GPU-context
stop, #14 and the test addresses), the merge of the four-node branch's v0.3.2 and the fix that keeps cache_salt on
compaction notes; the two-node recipe's pool of 2,097,152 positions and its v0.7.1. NOTICE names v0.3.2's cache_salt
and the DSML reader with their tests among the new files and compact_test.zig among the changed ones, and
ATTRIBUTION.md's #25 row names the two commits that carry #25's tests. ATTRIBUTION.md adds two reports, @den13501's
(two-node recipe issue #15: the kit rebuild's mapping error, which #14 fixes) and @plyldavid-maker's (issue #25: the
ranks that waited on each other), and says what the export changed in v0.7.1's messages.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bertholomus added a commit that referenced this pull request Nov 2, 2026
…s it

A rank that stopped (an error, a crash, a kill) left the others waiting
inside their next exchange for good, their GPUs spinning on it: the
signature of tp2 #25's second hang. Each rank now watches its links
(link.Watch: a poll for the peer shutting its end, which frames never
set): when a peer rank goes and this process has not ended within 5 s,
it prints which rank went and exits 1. The server's rank 0 watches its
followers and the lane followers watch rank 0; rank 0's done, a follower
reading it and Model.close end the watch, so a clean shutdown is as
before. A follower that stops on an error also says why on stderr (its
stdout line stays for the gates).

Tests: a closed link is named and a frame on it is no close; a stopped
watch lets its links close quietly; the grace lets this process end
first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

2 participants