Repository navigation
feat(lanes): a prompt pass runs in pieces between the other streams' rounds (dsv41) - #29
Merged
bertholomus merged 2 commits intoOct 19, 2026
Conversation
Owner
…rounds (TF_FILL_CHUNKS, TF_FILL_ROUNDS) A prompt pass ran whole inside its admission, so every stream that was decoding stopped until it ended: on two GB10s a 400K-token prompt (a restarted agent session, or one whose state was lost) held the other sessions for ~4 min. The backend may offer prefill_part, the same pass in pieces of at most N chunks. When it does, TF_FILL_CHUNKS is set and another stream decodes, the lane core runs only the first piece at admission; the stream is then `filling` and fillStep runs a piece after every TF_FILL_ROUNDS rounds of the live streams (at once when none decodes), then draws its first token and joins the rounds. One pass fills at a time: the host admits the next request when it ends. A cancel or an error in a piece ends that request alone. dsv41: prefillFn becomes an opening (slot, extent, images, rank 1's fill, the kept state) and resumable chunks; the chunk loop's state lives in Lanes.fill between pieces. A piece ends with the read-ahead joined and the prompt's ids gone, as rank 1 does at any other frame, so both ranks run the same frames in the same order; rank 1 reads ahead again at the next chunk. Rounds leave the fill's view, rings, spans and image rows alone; the Engram read-ahead of a chunk is redone when none is pending. Unset, every pass runs whole as before. Test: a lane host with a stream decoding admits a six-chunk prompt; the decoding stream delivers tokens between every two pieces, and the new reply equals the fake's continuation of its prompt.
… prompt runs whole (TF_FILL_FIRST) Each piece ended with the next chunk's Engram read-ahead joined, and that chunk, finding no read-ahead pending, read its rows from the drive again: every chunk of a pass in pieces was read twice, and a 31K-token prompt went at ~1,500 tok/s instead of ~2,100. A chunk now takes rows read ahead that ended before it when they cover it, both layers: they sit in the read-ahead's own buffers, which rounds leave alone (a round's Engram reads use the host's others). A prompt's fill invalidates what was read ahead for another, so rows never cross prompts at the same positions. TF_FILL_FIRST=N: the first piece runs N chunks, so a turn's new tokens within it run whole, as before. Test: a prompt within the first piece runs whole, the decoding stream waiting for it.
hashd1ve
force-pushed
the
dsv41-interleave-pr
branch
from
October 19, 2026 15:58
70ab7ab to
78152f2
Compare
Author
|
Done: rebased onto deepseek-v41-zig without the first commit. The resulting tree is byte-identical to the one I tested ( |
Owner
|
Merged, thank you @hashd1ve! It went in exactly as tested. A long prompt no longer stops the other sessions, and the read-ahead fix keeps the pieces fast. Thanks also for the quick rebase. |
bertholomus
added a commit
that referenced
this pull request
Oct 21, 2026
…s (TF #29 on TP4), off unless TF_FILL_CHUNKS is set TF #29 by @hashd1ve (a27d2f0 + 45c25b1 on deepseek-v41-zig) on TP4's 1.0.12 lane core, devchain dsv41tp4 d125. TF_FILL_CHUNKS=N steps a prompt pass N chunks of 2048 rows at a time (TF_FILL_FIRST: its first step's chunks), and the lane host runs TF_FILL_ROUNDS (default 4) rounds of the live streams between two steps, so a long prompt no longer stops the replies that stream meanwhile. Unset, as served, the family hands the lane core the entries it handed before (no prefill_step), and every pass runs whole as before. - core: Backend.VTable.prefill_one (a backend that holds one prompt pass at a time: the lane host admits the next request once the pass ends, so its kept-state lookup finds what that pass kept); Info.fill_rounds (the rounds between two steps of a pass that began); a first step that the pool cannot place yet (ContextFull) while other streams run is requeued as admission does. The CUDA wrapper and the recorder forward prefill_one. - dsv41: #29's family half (the pass state Fill; prefillPart and fillOpen; release ends a pass in pieces; a follower's piece after a round reads ahead again; the read-ahead reset at fillBegin and kept when it covers the chunk); steps_vt only when TF_FILL_CHUNKS > 0. - tests: one pass at a time; fill_rounds rounds between two steps; both vtables forward the same entries but the step. Co-Authored-By: Manrique <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit a24de00c5e5bb8109ab9528c25b399692f74c217)
bertholomus
added a commit
that referenced
this pull request
Oct 21, 2026
The kept-states stack of fill29 (a shared prefix no longer stales the first conversation's kept states; prompts with lane images keep their states, keyed by the images' digests; a resumed prompt skips the vision tower for the images it holds; TF_FILL_CHUNKS, unset as served) onto zdirdb's candidate ffa2f163 (the shield, structured output, reply ids, DSML for tool_choice required, the stats line, d143). Conflicts: - families/dsv41/lanes.zig: both sides' fields and release; structured output's first_masked and held in whole_vt (steps_vt copies it); the grammar's kept first row in prefillPart after the first token's draw (the lane core draws it in the same step: open.zig fillStream, opened, drawFirst); both sides' tests. - server/prompt.zig: the history renders as the prompt does (renderIdsOf with the lane images), so with TENSORFOLD_PLAIN_SPECIALS a lane image's placeholder stays the template's in both and #28's history length holds; text requests render as before. Every other file's change against dc464126 (5f1b1cbe + d143) is ffa2f163's against 89872573 (fbee5419 + d143). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bertholomus
added a commit
that referenced
this pull request
Oct 21, 2026
The four-node line that serves DeepSeek-V4.1-Flash-1017 on four GB10 nodes comes in as its own commits since v0.2.0 (22, six of them merges). This merge keeps the branch a fast-forward of its head with pull requests #30 and #31 (b8b115e). Against v0.2.0: - A replay cut uploads its rows' positions into the chunk's aligned buffer (a prompt resumed after a kept text prefix no longer stops with MissingTritonVariant). - Kept prompt states: pull request #26 (@hashd1ve), a prefix two conversations share no longer stales the first one's kept states; prompts with lane images keep and resume their states, matched by the images' digests (after #28 by @hashd1ve), and a resumed prompt skips the vision tower for the images its kept state holds; a kept state the lanes would refuse is passed over for an earlier one. - TENSORFOLD_PLAIN_SPECIALS: a sender's special-token text stays text, and a lane-vision engine's image placeholders stay its image tokens. - Structured output (response_format json_object and json_schema) through libtfgrammar; TENSORFOLD_GRAMMAR_LIB names its file. - tool_choice "required" and a named function write DeepSeek's DSML calls block, and a forced call's marker is always its token. - The served sampler draws top_k off (0 and -1) and any top_k. - The draft head's chains counted by depth for /metrics, with an optional stats line (TENSORFOLD_STATS_EVERY). - Off unless set: TF_FILL_CHUNKS (#29 by @hashd1ve, on TP4: a prompt pass in pieces between the other streams' rounds) and TENSORFOLD_REPLY_IDS. Both sides changed zig/src/families/dsv41/model.zig and prompt.zig. model.zig takes both: #30's neighbor gather beside the served line's changes. prompt.zig keeps the served line's replayCut, which uploads every cut's surviving positions into the chunk's own buffer; #31 uploads them for small odd cuts and keeps the view otherwise, and the positions are the same. #31's CPU test follows the served replayCut (one upload for every cut) and passes on it, and replay_positions.md says so; the v0.2.0 baseline still fails it as the document says. Every other file is one side's: 40 the served line's, 17 this branch's. With TF_DS_NEIGHBOR_RDMA unset, #30 opens no neighbor gather and every exchange takes the path it took before. Rank 0's startup settings now carry the neighbor mode (48 bytes, 40 before), so every rank runs the same build. Thanks @swbiggart for #30 and @mrsergiopascal for #31. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bertholomus
added a commit
that referenced
this pull request
Oct 21, 2026
…, forced tool calls, five contributions The README's fork note adds what the branch serves since v0.3.0: kept prompt states for image turns too, a shared 4,194,304-position window, structured output and forced tool calls in DeepSeek's DSML. NOTICE lists the new files (the prompt shield's, and the neighbor transport's document and receipts), every upstream file the branch changes against 1.0.12 (16 more since v0.2.0) and the contributions: Manrique's pull requests #26, #28 and #29, Scott Woolsey Biggart's #30 and mrsergiopascal's #31. ATTRIBUTION.md adds them, the ideas taken from DeepSeek's DeepInfer and from xgrammar's structural tags, and @den13501's report behind the stream keepalive. The family's section of THIRD_PARTY_NOTICES.md names libtfgrammar in a deployment's kit. The fork note also thanks the branch's contributors by name. ATTRIBUTION.md says that the EXL3 kernel code copied from TensorFold's Python line was written before 0.6.0 and keeps its MIT notice (LICENSES/MIT.txt), and names the co-authors the commits' trailers name. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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
A prompt pass can run in pieces between the other streams' rounds. Before, a pass ran whole inside its admission, so every stream that was decoding stopped until it ended. On two GB10s, a 400K-token prompt (a restarted agent session, or one whose state was gone) held the other sessions for ~4 min.
Builds on #28 (image caching): this branch carries its commit. Review that one first.
Backend.prefill_partis optional: the same pass in pieces of at most N chunks. WithTF_FILL_CHUNKSset and another stream decoding, the lane core runs only the first piece at admission. The stream is thenfilling, andfillStepruns a piece after everyTF_FILL_ROUNDSrounds of the live streams (at once when none decodes). When the pass ends, the stream draws its first token and joins the rounds.TF_FILL_FIRSTsets the first piece's chunks, so a turn's new tokens within it run whole, as before.prefillFnbecomes an opening (slot, extent, images, rank 1's fill, the kept state) plus resumable chunks, with the loop's state inLanes.fill.fillBegininvalidates them for each prompt.Receipt
Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision:
deepseek-v41-zigat629c524aplus 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 at2913ea75. Served with--context 1048576 --parallel 4, drafts and CUDA graphs on. The live checks below ran on our served build, which is this branch plus fix(server): DSML calls read from their own tags in the native server (the native side of #20) #25.Exactness, from
tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: not run. Instead, 12 greedy chat prompts give byte-identical text to the unpatched engine; a ~7K-token prompt resumed from its kept state, and again after another conversation, gives the same reply as fresh;/tokenizeids for 1,500 random conversations are unchanged.Decode speed before and after, from
tools/bench_openai.py: not run. The recipe'skit_bench.py decode --set agives prose 57.0 → 56.9 and structured 104.9 → 104.3 tok/s.Tests run, with pass, fail and skip counts:
zig build test(CUDA host tests, aarch64 Linux) on this branch: 222 pass, 0 fail, 0 skip.Prompt speed before and after, from
tools/prefill_cold.py: not run. With nothing else decoding, a pass runs whole as before.For this change, on the server: A streams a long greedy reply; B, a new 56,840-token prompt, arrives meanwhile. Then B is sent again (resumed).
TF_FILL_CHUNKS=1 TF_FILL_ROUNDS=4 TF_FILL_FIRST=4)The 3.8 s are the rounds A gets meanwhile. A first version that dropped each piece's read-ahead and read every chunk twice took 38.4 s; the second commit fixes that.
New tests (lane host, fake backend), both failing before this change:
Not run, and why: Metal (no Mac set up for this branch; the core change is backend-neutral, and only dsv41 offers
prefill_part); the three tools above.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (B interleaved = B resumed alone, and resumed = fresh; draft:false not run)