Skip to content

qwen27 Metal (M1-M4): solo prompt passes take the frame's rows, not 128 (#2907) - #2916

Merged
ashhart merged 13 commits into
mainfrom
lead/q27-pre-m5-solo-prompt
Nov 24, 2026
Merged

ashhart merged 13 commits into
mainfrom
lead/q27-pre-m5-solo-prompt

Conversation

@ashhart

@ashhart ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Fixes #2907.

On M1-M4, a Qwen3.8-27B prompt pass was capped at 128 rows though the frame is 512 by default (and TF_PROMPT_ROWS accepts up to 2,048).

  • Geometry.solo_prompt (default false) lets one chain of prompt rows take the frame's rows before tensor units. It's set only where the prompt kernels build.
  • Decoded spans, verifies and trees keep 128-row plans before M5, and are still refused past them. A prompt beside a live decoder stays at 128 rows before M5 (512 with tensor units), so a decoder isn't stalled longer.
  • Attention scratch is sized per chunk, and the layout check follows it.

Exact by design: every kernel is invariant to pass length.

Tests: six old-behaviour controls fail against unchanged main and pass here: 128-row solo planning, the 512-row live-decoder cap before M5, the decoded-span cap, decodeRows, the old layout and the old scratch guard. The maintained tests plan 512- and 2,048-row solo chains and still refuse 129-row trees, non-solo chains and two-window aggregates. qwen27 host 592/593 (1 skipped).

Not yet checked on a device: on an M3 Ultra, tf-qwen27-run --chunk 512 --compare-chunk 16 --seams 2048 and --chunk 2048 --compare-chunk 128 byte-equal, tf-qwen27-attention-precision --prompt at 512 rows, and the A/B against main and #2797 (expected +1-3% on cold prompts). Whichever wins lands; if this wins, #2797 closes and keeps its doc fix.

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

/atc exchange 77a30b22da0dc16d3a0e4c970ad76224d9bd2683fc5de2a2d981b645a07da307

ashhart added a commit that referenced this pull request Nov 18, 2026
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
@ashhart
ashhart force-pushed the lead/q27-pre-m5-solo-prompt branch from fa10c4f to b6982ba Compare November 18, 2026 02:26
ashhart added a commit that referenced this pull request Nov 19, 2026
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
@ashhart
ashhart force-pushed the lead/q27-pre-m5-solo-prompt branch from b6982ba to ec85a00 Compare November 19, 2026 01:19
ashhart added a commit that referenced this pull request Nov 21, 2026
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
ashhart added a commit that referenced this pull request Nov 21, 2026
…fromConfig

The rebase kept main's `const geometry` from Geometry.fromConfig; #2916 sets
geometry.solo_prompt once the prompt kernels build, so it is a var again.
@ashhart
ashhart force-pushed the lead/q27-pre-m5-solo-prompt branch from ec85a00 to 90c3fce Compare November 21, 2026 17:07
ashhart added a commit that referenced this pull request Nov 22, 2026
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
ashhart added a commit that referenced this pull request Nov 22, 2026
…fromConfig

The rebase kept main's `const geometry` from Geometry.fromConfig; #2916 sets
geometry.solo_prompt once the prompt kernels build, so it is a var again.
@ashhart
ashhart force-pushed the lead/q27-pre-m5-solo-prompt branch from 90c3fce to f8935b6 Compare November 22, 2026 03:02
@joshuaswarren

Copy link
Copy Markdown
Contributor

Pre-M5 datapoint from an M1 Ultra (this head f8935b6 vs main 7d243251, Qwen3.8-27B-MLX-4bit + DFlash2, one stream, ~9,006-token cold prompts, --prompt-cache-gib 0):

Default config: both builds already run solo prompt passes at the frame's rows — prefill_widths [512 x 17, tail] on both, prefill_seconds ~88 s on both. The fused shared-prefix chain path already covers the solo case on main, so this change is a no-op for default solo prompts on this host.

TF_QWEN27_SHARED_PREFIX=0 (the unfused-plan case this PR targets): both builds run [128 x 70, 41, 5] — the wide pass did not engage. geometry.solo_prompt ends up false here because it requires model.kernels.prompt, and this M1 build has no prompt kernel (the server also reports prompt capacity=128 rows in this config). So on M1 Ultra the lever cannot fire; the issue's premise only holds on an M1-M4 chip where the simdgroup prompt kernel qualifies — worth confirming on the M3 Ultra leg which chips actually build it.

Incidental: on this host the 128-row unfused path prefilled faster than the fused 512-row path (82.6 s vs 88.1 s for ~9k tokens, one rep each) — the wider pass may not be the faster shape on pre-M5 memory bandwidth.

Exactness: decode digests byte-identical to main in every arm.

ashhart added a commit that referenced this pull request Nov 23, 2026
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
ashhart added a commit that referenced this pull request Nov 23, 2026
…fromConfig

The rebase kept main's `const geometry` from Geometry.fromConfig; #2916 sets
geometry.solo_prompt once the prompt kernels build, so it is a var again.
@ashhart
ashhart force-pushed the lead/q27-pre-m5-solo-prompt branch from f8935b6 to ba23deb Compare November 23, 2026 20:50
ashhart added a commit that referenced this pull request Nov 24, 2026
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
ashhart added a commit that referenced this pull request Nov 24, 2026
…fromConfig

The rebase kept main's `const geometry` from Geometry.fromConfig; #2916 sets
geometry.solo_prompt once the prompt kernels build, so it is a var again.
@ashhart
ashhart force-pushed the lead/q27-pre-m5-solo-prompt branch from ba23deb to 84f61d4 Compare November 24, 2026 09:01
Keep the current depth argument in the imported row regressions. Pin every changed serving source by its raw SHA-256 and describe the prompt-frame change under Unreleased.
…rompt rows

Main had blank separators the rebased PR did not; with the solo prompt fields each file reached 602 and 605 lines. Five and two blank separators were dropped so both files are 600 lines, with every statement unchanged.
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
…fromConfig

The rebase kept main's `const geometry` from Geometry.fromConfig; #2916 sets
geometry.solo_prompt once the prompt kernels build, so it is a var again.
…a37382

attention_plan.zig, decode_round.zig and qwen27_slots.zig now hold main's
per-slot window capacity beside this change's solo prompt rows, so their
pins move to the rebased bytes. No source changes.
@ashhart
ashhart force-pushed the lead/q27-pre-m5-solo-prompt branch from 84f61d4 to 18c40a3 Compare November 24, 2026 14:46
@ashhart
ashhart merged commit 510a8d5 into main Nov 24, 2026
2 of 12 checks passed
ashhart added a commit that referenced this pull request Nov 24, 2026
attention, attention_memory, attention_plan and decode_round carry main's extra mates field and prompt-plan pair, so their raw hashes changed; the six #2916 pins now match the rebased files.
ashhart added a commit that referenced this pull request Nov 24, 2026
…fromConfig

The rebase kept main's `const geometry` from Geometry.fromConfig; #2916 sets
geometry.solo_prompt once the prompt kernels build, so it is a var again.
@ashhart
ashhart deleted the lead/q27-pre-m5-solo-prompt branch November 24, 2026 14:46
ashhart added a commit that referenced this pull request Nov 24, 2026
ashhart added a commit that referenced this pull request Nov 24, 2026
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.

qwen27 Metal (M1-M4): solo prompt passes capped at 128 rows though the frame is 512

2 participants