Repository navigation
flash next hip: deferred kept-state saves, a pinned bounce buffer, small pages (@llstrk, Strix 4/12) - #3647
Merged
Conversation
ashhart
force-pushed
the
lead/strix-s4
branch
3 times, most recently
from
November 21, 2026 08:49
016b4fe to
5c206da
Compare
…prompt does not wait on allocating and clearing them
…ads, the next while one uploads (the n-gram layer stays mapped)
…parts, not 32, so more of its page reads wait together (same bytes)
…cache takes no more than the streams leave (--prompt-cache-gib still sets it)
snapBytes, snapSave, snapRestore and snapDrop move from lanes.zig to lanes_states.zig as bytes, save, restore and drop, unchanged, so the next change keeps lanes.zig under 600 lines. Fx.of and Fx.send become pub for them.
…s it (same state bytes) The prompt cache keeps a state at the history's end, a few tokens before the prompt's (its generation suffix), and the fill stopped there: a chunk to the row, then a last chunk of the 25-65 rows past it. A chunk of so few rows still streams nearly every weight (its rows route to most experts): ~300 ms on mix5, ~3% of a 14K prompt. The chunk now runs on past the row (to the prompt's end or the next kept row) with a forward.Mark: mixers.linear runs the conv and the delta rule to the row and on from it (the same launches a chunk ending there and the next make), writing the conv and delta states at the row aside; ple copies the n-gram tail at the row aside. snapshot.saveMarked then keeps the sparse layers' rows below the row from the caches (no later row changes them) and the rest from the side buffer, with the pooled count and n-gram history a chunk ending at the row leaves. The side buffer is the lane's window snapshots, free while its prompt fills (no new memory); without room, or with ranks linked, the chunk stops as before. Checks: the kept states' bytes (main and head) hashed identical to stopping for all six of pftest's keeps (3.5K-28K, a row in a second chunk among them); turn-2 requests that resume from them give the same replies under both policies (12K, 28K, 5K; resumed at 10176, 23808, 4224); pftest hashes unchanged (161c7d0680fb / da163ea80daa, defaults 65dfcd8ddd0f). Model, opt-in set, cooled interleaved x3: 16K 1,331-1,370 vs 1,293-1,336 tok/s, 32K 1,310-1,315 vs 1,276-1,307; the final build 1,359 / 1,373 and 1,323.
…e buffers hold, so the prompt cache's marks no longer cut an 8K prompt into two chunks (same bytes kept)
…'s kept states are saved (first_before_draft; the saves wait for the stream's next step, the state unchanged till then)
…32 MiB buffer made with the store, so a request pins no pages of its own (a pageable copy that big pinned them, which compacted the host's free pages under the running kernels; same bytes)
… of their own (MADV_NOHUGEPAGE), so a state's huge-page faults no longer compact the host's free pages under the running kernels after a direct load (same bytes)
ashhart
force-pushed
the
lead/strix-s4
branch
from
November 21, 2026 11:26
5c206da to
550d808
Compare
Owner
Author
|
Thank you @llstrk. This is merged into main with your commits under your own name, so you're credited as a TensorFold contributor. |
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.
Adopts part 4 of 12 of @llstrk's Strix Halo (gfx1151) work for Qwen3.8 Flash Next on HIP: deferred kept-state saves, one pinned bounce buffer and small pages. His commits keep his authorship; the last commit is ours (changelog line and comment folding). Only his exact default path is adopted; the opt-in settings that change tokens are not.
Stacked on the series before it (#3646); review the last commits here, the earlier ones are that PR's.
What changes. A prompt's first token goes out before its last chunk's kept states are saved. Kept-state copies pass through one pinned 32 MiB buffer made with the store, and the state bytes are mapped on small pages so host pages don't compact under the running kernels.
Checked so far.
Before it lands: served checks on gfx1151 with Qwen3.8-Flash-Next-MLX-4bit-MTP, main against this head. Deferred saves settle before any state changes, through cancel, close, reuse and follower work; state bytes before and after the deferred first token; the bounce fallback at chunk edges; repeated restores; peak pinned and host bytes; steady-state first-token time. Compare complete token-ID arrays, greedy and seeded, prose and code, 2K/8K/32K/64K prompts. Our Strix can't hold the 105 GiB checkpoint yet, so @llstrk, if you can run these on your box at this head with the default policy (no
TF_POLICYkeys), that settles it; otherwise we will once our disk is grown.Thanks to @llstrk for the work and the measurements.