Skip to content

flash next hip: deferred kept-state saves, a pinned bounce buffer, small pages (@llstrk, Strix 4/12) - #3647

Merged
ashhart merged 14 commits into
mainfrom
lead/strix-s4
Nov 21, 2026
Merged

ashhart merged 14 commits into
mainfrom
lead/strix-s4

Conversation

@ashhart

@ashhart ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

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.

  • Our Strix Halo (gfx1151, ROCm 7.1): the HIP kernel tests pass, and the HIP kernel contract gives the same result here as on main 077998f: 161 kernels pass gates 1-4, 0 fail, the same 2 known findings, all 42 planted controls red. (The box's compiler leaves the same 174 resource records stale on main and here.)
  • Host steps for the HIP native and proposal paths pass, and lean has no new problems.

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_POLICY keys), that settles it; otherwise we will once our disk is grown.

Thanks to @llstrk for the work and the measurements.

  • Synthena

llstrk and others added 14 commits November 21, 2026 11:26
…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
ashhart merged commit 3c7dd3a into main Nov 21, 2026
2 of 12 checks passed
@ashhart
ashhart deleted the lead/strix-s4 branch November 21, 2026 11:27
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
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.

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