Skip to content

flashnext metal: tensor units take the default decode share and growing prompt steps - #2394

Merged
ashhart merged 2 commits into
mainfrom
lead/m5-share
Nov 7, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/m5-share

Conversation

@ashhart

@ashhart ashhart commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

What this changes

On a Mac with tensor units (M5), Flash Next at an explicit --parallel 2 or more broke from the other Macs' defaults in two ways:

  • prefill.shareOf gave a filling prompt no decode share.
  • fill_grows stayed off, so beside a running reply the prompt took 32-row steps for its whole length.

Each slowed the other. Now every Mac takes the same defaults: replies take 0.8 of a fill step's time, and a prompt's steps grow to 512 rows after eight.

--decode-share and TENSORFOLD_PREFILL_SHARE keep their meanings, and --decode-share 0 still prefills each prompt whole. --parallel auto still uses the single host. Chips without tensor units run exactly what they ran before, since both removed conditions were true only on tensor units.

Checks on this head

  • Head commit: c45c59b19. It is the same code as 0b1983b58, rebased onto main 18ecc42d6 past a CHANGELOG-only conflict.
  • Lean checker on the base and on this head: 180 and 180 problems, 0 new.
  • Tests run:
    • zig build test: 715 / 715 steps, 0 failures. test-flashnext-scheduling-host passes.
    • One host test, exl3_load's allocation sweep, also fails on main when the checkout sits in one particular folder here, and passes from another, with and without this change. It is unrelated to this PR, and I'll look at it apart.
  • CI: pending.
  • Not run, and why:
    • M1 to M4: their path is unchanged.
    • CUDA: this is the Metal host only.

Receipt

  • Environment: M5 Ultra; TensorFold/Qwen3.8-Flash-Next-MLX-4bit-MTP at 2b170fa6; ReleaseFast -Dcpu=apple_m1; one fresh server per arm; order warm, main, new, new, main; greedy with ignore_eos.

    • Base: main 8bf5dbc35. Measured: bb640e015, which is this head's code before its rebase and its known-issues line.
  • Exactness: every request's token hash is equal across every arm, main's and this PR's: 12 of 12 two-client requests, and both orders of the 64K cell. Drafts were on (MTP) throughout.

  • Two clients at once, prompt cache 8 GiB, --context 73728. An agent sends 6 growing turns (16K tokens, then 6K new a turn, 128-token replies) beside 6 short asks with 768-token replies:

    --parallel 2, no share flag main this PR
    Both done 127.1, 127.7 s 47.1, 47.2 s
    Agent's first tokens, summed 120.6, 121.1 s 41.4, 41.5 s
    Asks done 124.5, 125.2 s 43.1, 43.2 s
    Asks' first tokens, summed 1.8, 1.9 s 6.7, 6.7 s

    On the same box: --parallel 1 finishes both in 40.2 s, with the asks' first tokens summing to 13.7 s. This PR with --decode-share 0.95 takes 43.8 s, with 8.5 s.

  • A 64K-token prompt beside a 1,024-token reply, prompt cache off, each order once a run:

    --parallel 2, no share flag main this PR
    Both done, reply first / prompt first 35.5, 35.6 / 38.1, 38.5 s 21.4, 21.5 / 21.2, 21.4 s
    The reply 21.8 to 25.6 s (40 to 47 tok/s) 6.8 to 7.3 s (140 to 151 tok/s)
    The prompt's first token 34.3 to 38.1 s 20.2 to 21.0 s
    The reply's longest pause 114 to 119 ms 225 to 229 ms

    Alone, the reply takes 4.9 s and the prompt 14.4 s. --parallel 1 gave 19.0 to 19.2 s for both, on main 86cfc3556.

  • Decode and prompt speed at one stream: --parallel 1 and auto run the single host, which this doesn't reach. At --parallel 2, the cells above time decode beside a prompt and the prompt beside a reply.

  • Licence of any new weights or drafter: n/a.

What it costs, and why:

  • An ask's first token comes about 0.8 s later than on main. There, the agent's prompt crawled in 32-row steps, so a short prompt rarely waited behind a pass. Each ask still finishes three times sooner.
  • Beside a 64K prompt, the reply's longest pause grows to about 0.23 s, one 512-row step at that length. Its typical gap falls: p95 35 ms, against 105.
  • A lane trace of a two-client run on main with --decode-share 0.8 shows the cost of 32-row steps on M5. Each one beside a reply took about 76 ms, ten times what its rows take at full speed: about 5 s of a 49 s run.

Still open on #1893, as docs/known-issues.md now says: on M5, --parallel 2 remains slower than --parallel 1, 47 s against 40 s with two clients. A higher share and longer steps both help: 43.8 s at 0.95, and 44.1 s with 2,048-row steps at 0.8. The next measurements are 512-row steps from the start on tensor units, and the lone driver at --parallel 2, which is still off on tensor units.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (The share test pins the new two-argument rule. It doesn't build against main's three-argument shareOf, so I can't show it failing there.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Scheduling only: replies equal main's in every arm.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No bits change.)
  • Decode and prompt processing are no slower than main at one stream and the widest admitted. (One stream is untouched. At --parallel 2, an ask's first token comes about 0.8 s later, as above.)

…ng prompt steps

On a chip with tensor units, an explicit --parallel 2 or more gave a filling prompt no decode share and kept its
steps beside a running reply at 32 rows, so each slowed the other. The shared host now gives every Mac the same
default: replies take 0.8 of a fill step's time and a prompt's steps grow to 512 rows after eight. The flag and
TENSORFOLD_PREFILL_SHARE keep their meanings, and --parallel auto still uses the single host.
@ashhart
ashhart merged commit eb15938 into main Nov 7, 2026
0 of 11 checks passed
@ashhart
ashhart deleted the lead/m5-share branch November 10, 2026 16:34
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