Repository navigation
Conversation
…ke rounds while a prompt fills The prompt pass splits into an opening (restore, images) and one chunk a step on the same cut grid; cancel_prefill keeps the last landed chunk. A stream mid-fill is never promoted into slot 0, and one image prompt fills at a time.
…e not waited for on the engine thread A dropped state's buffer goes to a size-class spare pool (the store's charged/spare/trim/reuses). saveSlot commits its blit; the slot's next write (reset, next prompt chunk, first round, move) and the state's first read wait for it.
…nside the finished stream's release
ashhart
added a commit
that referenced
this pull request
Oct 25, 2026
Owner
|
Landed on main (94d9a6a..0941f86), stacked on #1303, under your authorship. Thank you! One conflict with #1262's change on main ( - Synthema, Ash's AI Assistant. |
ashhart
added a commit
that referenced
this pull request
Oct 25, 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.
Stacked on #1303: the first commit here is #1303's.
When a stream finished, its release ran on the engine thread at the end of a round:
moveSlot) then blitted the next stream in, synchronously.Prompt marks inside a prompt pass paid the same new-buffer-and-wait between chunks, and every other live stream's next round waited behind all of this.
A streamed reply's close (last token to the end of the response) was already about 0.4 ms on main, because the reply is out before the sweep runs. What this saves is engine-thread time the other streams were waiting on.
Receipts: same machine, models and test-only setting as #1303. All replies are identical to main; drafted == plain, concurrent == solo and resumed == fresh hold;
zig build testpasses on macOS and Linux;tf-qwen27-markspasses on real weights at every mark. The timing comes from an uncommitted timer around the same code in both builds, DFlash2,--parallel 2, over 10 saves (reply ends and prompt marks, up to a 6.8k-token state).Design:
snapshot.Sparesputs a dropped state's buffer in a four-entry pool. Buffers are sized n + n/8, in 32 MiB steps, and a save takes a spare up to 1.5x its size. The store sees the pool throughcharged,spare,trimandreuses, and the prompt-mark room check counts a reused buffer as no new bytes.saveSlotcommits its blit and returns, and the state holds the retained command buffer.State.landed()waits before any read of it: restore, the disk gather and drop.Runner.reading[slot]makes the slot's next writer wait for the blit. Those writers are its reset (which covers rebinding, restore and the hand-over), the next prompt chunk, and the end of the prompt before its first round.promote_due, and the move runs at the next draft, verify, queue or prefill call, once no round is pending.Not covered:
--learndisk writes of a just-saved state. The gather waits for the save first, but this wasn't exercised.