Skip to content

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

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

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

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

What this changes

LFM3 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-lfm3-metal-steps-host: 5/5 (4 named tests plus an import block); 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.

…alls other streams' rounds

LFM3's Metal backend gains prefill_step and cancel_prefill (#3021). Each call
runs one chunk at exactly the whole pass's cuts (the chunk cap, the next
planned start, the next kept mark); LFM3 declares no chunk invariance, so
max_rows is ignored and the cuts never move. The whole pass and the steps
share one chunk body, so replies are unchanged.

A cancel keeps the state at the last chunk's end; a stream that leaves
mid-pass is forgotten; image rows are prepared once, at the first call.
The whole pass still yields at chunk starts as before.

Host tests on recording fakes: stepped chunks equal the whole loop's, a
resumed pass cuts as main does, a cancel keeps the last chunk's end, and
another stream decodes between two chunks. The new step joins the macOS
host CI list, and check-metal-prefill-rest-host compiles the new bodies.

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