Skip to content

qwen3_5 metal: prefill runs a chunk a call, so a new prompt no longer stalls other streams' rounds (#3021) - #3090

Open
ashhart wants to merge 1 commit into
mainfrom
lead/qwen35-metal-prefill-step
Open

ashhart wants to merge 1 commit into
mainfrom
lead/qwen35-metal-prefill-step

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

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_step and cancel_prefill beside reports_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.

Checks on this head

  • Lean checker: 0 new; every file under 600 lines. zig fmt --check: clean.
  • test-qwen35-metal-steps-host: 7/7; test-qwen35-cache-host: 23/23; check-qwen35-cache-host passes; check-metal-prefill-rest-host passes (it compiles the real prefill, prefill_step and cancel_prefill bodies).
  • Not run here: the Metal device steps. We'll run them on an M5 Mac before landing.

Receipt

  • Main against branch: owed, on an M5 Mac: replies byte-identical to main at T=0 and seeded, including a long prompt arriving while another stream decodes, a prompt-cache resume from a mark and a cancel mid-pass; lone decode and lone TTFT within run-to-run noise.

Checklist

  • The title and description match the head commit.
  • Comments and docstrings are one line.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

…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

No deployments
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.

1 participant