Repository navigation
Conversation
…stalls other streams' rounds Qwen3.5-2B's Metal backend gains prefill_step and cancel_prefill (#3021). prefill.run becomes open (main's restore of a kept prefix) and step (one turn of main's loop), and the whole pass is open plus steps, so both drivers run the same chunk body and replies are unchanged. Each call runs one chunk at exactly the whole pass's cuts (the chunk cap, the next planned start, the next kept mark); Qwen3.5 declares no chunk invariance, so max_rows is ignored and the cuts never move. The GDN and conv state live in the stream's cache, so a step carries only its next row between calls. A cancel keeps the state at the last chunk's end; a stream that leaves mid-pass is forgotten, its paged lane released. Host tests on host-backed caches with a sentinel forward: stepped chunks equal the whole loop's and leave the same state byte for byte, a resumed pass cuts as main does, a cancel keeps the last chunk's end, and another stream decodes between two chunks of a long prompt. The new step joins the macOS host CI list.
This branch has not been deployed
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
Qwen3.5-2B on Metal ran a new stream's whole prompt in one call on the lane thread, so with shared rounds every other stream's reply waited for the whole prefill. The backend now declares
prefill_stepandcancel_prefillbesidereports_fill, so the lane host runs one chunk a call and decode rounds run between chunks, as Gemma 4 (#3025), Nemotron (#3054) and LFM2-MoE (#3058) do.Same cuts: one chunk a call at exactly today's cuts. Qwen3.5-2B declares no chunk invariance, so the host never caps a step and the cuts never move. The whole pass and the stepped one share the same chunk body.
The GatedDeltaNet state lives in the cache and advances chunk by chunk as before; a next row per stream makes the pass resumable.
Cancel between chunks keeps the state at the last chunk's end; a stream that leaves mid-pass is forgotten.
Sizes:
prefill.zig42 → 61 lines (runis nowopenplusstep, each step calling the samepromptChunk);backend.zig256 → 290; new testzig/src/qwen35_prefill_steps_test.zig(300). The new host step is in the macOS host CI list.On cost: an M5 matrix on gemma4 metal: prefill runs a chunk a call, so a new prompt no longer freezes other streams' decode (#3021) #3025 showed lone decode level with main (earlier gaps were run-to-run noise), and a new prompt's first token arriving later while other streams decode is the interleaved rounds, the point of Gemma 4 on Metal: a new prompt freezes every other stream's decode for its whole prefill (no prefill stepping) #3021.
Issue: Refs Gemma 4 on Metal: a new prompt freezes every other stream's decode for its whole prefill (no prefill stepping) #3021.
Stacked on: main. Small adjacent-line conflicts with lfm2_moe metal: prefill runs a chunk a call, so a new prompt no longer stalls other streams' rounds (#3021) #3058 in
prefill_widths_metal.zig/host_ci.zig; whichever lands second rebases.Checks on this head
zig fmt --check: clean.check-metal-prefill-rest-hostpasses (it compiles the real prefill, prefill_step and cancel_prefill bodies).Receipt
Checklist