Repository navigation
Conversation
…re-M5 path On GPUs with tensor units, Flash Next's decode skipped every M1-M4 decode choice: the row kernels for dense projections, grouped experts, the cost depth rule and gated lanes at tau 0.4. TF_FLASHNEXT_M5_ROWS=1 turns all four on for an M5 through rows_load.preM5Decode; prompts stay on the tensor units (their nax fragments are what an M5 needs) and the lane template is unchanged. Unset, an M5 decodes as before. On an M5 Ultra (512 GB), Qwen3.8-Flash-Next MLX 4-bit MTP, 16 prompts of 512 tokens, one stream, base/new/new/base: - greedy median 200.7 -> 235.4 tok/s (+16.0% mean rate, 0 of 16 slower) - sampled median 179.7 -> 226.7 tok/s (+16.8%) - "draft": false 108.4 -> 133.1 tok/s (+22%) - drafted == "draft": false on 16 of 16 in both modes; repeats 16 of 16 - unset: all 48 replies byte-identical to main before this change At --parallel 4 with staggered distinct prompts, every concurrent reply equals its solo run, but 4 streams are up to 6% slower (the row kernels' cost grows a row at a time where a tensor block is flat to 16 rows), so it stays opt-in. Tokens differ from the tensor-unit decode's (different summation order); the R1 quality cell (chat mode) passes, 39 of 40 exact answers on both, the same 64K needle result on both.
# Conflicts: # CHANGELOG.md
…ig, one-line comments The lean check refused rows_load.zig's direct getenv of TF_FLASHNEXT_M5_ROWS and its multi-line comments. The setting is now a .metal flag in environment.zig's table (0 or 1; any other value is refused at startup with its name and forms), read once in finishLoad into Run.m5_rows beside sb_index. rows_load.on and preM5Decode take the run instead of the device. environment_test covers the new row; docs/environment.md says exactly 0 or 1. On an M5 Ultra the replies are unchanged: default and TF_FLASHNEXT_M5_ROWS=1 each match the previous build on 32 of 32 replies (16 prompts, greedy and sampled), and TF_FLASHNEXT_M5_ROWS=2 is refused. lean: 0 new. zig build native, test-native and test-environment-host pass; zig build -Dfixed-cpu test fails only the dashboard test that also fails on main on that Mac.
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
Owner
Author
|
Closing.
|
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.
On a Mac with tensor units (M5), Flash Next's decode skips every choice the M1-M4 decode makes: the row kernels for dense projections, grouped experts, the cost depth rule and gated lanes at tau 0.4. On an M5 Ultra that left one stream at about the speed of an M3 Ultra.
TF_FLASHNEXT_M5_ROWS=1turns all four on for an M5. It is opt-in because four streams get slower.TF_FLASHNEXT_M5_ROWSis a.metalflag inplatform/environment.zig(exactly0or1; any other value is refused at startup), read once at load intoRun.m5_rows.rows_load.preM5Decode(run)decides it: true on every GPU without tensor units, and on one with them when the flag is1.rows_load.on, the grouped-experts check and the gate default inengine_load.zig, and the cost depth rule inengine_generate.zigread it in place of!tensorUnits().nax.h's fragment layout is wrong).lane_qmm_bytes_grouped's-lanesvariant) is unchanged. On an M5 it accepts no drafts at all, so it stays off."draft": false) are byte-identical to main before this change.Measured on an M5 Ultra (512 GB), Qwen3.8-Flash-Next MLX 4-bit MTP at 2b170fa6, one server per arm, base/new/new/base, on an otherwise idle machine:
tools/bench_prompts.json), 512 tokensTF_FLASHNEXT_M5_ROWS=1"draft": false, median tok/s"draft": falseon 16 of 16 prompts in both modes, and repeated arms give the same tokens 16 of 16 times.--parallel 4with distinct prompts staggered 150 ms apart (bench_concurrent.py --alone), every concurrent reply equals its solo run in both modes. Sampled: +23.6% at one stream, +3.1% at two, −6.4% at four. Greedy on the copy-heavy quicksort prompt: −3.8% / −5.6% / −6.4% at one, two and four streams. The row kernels' cost grows a row at a time, while a tensor-unit op costs the same up to 16 rows. So narrow rounds favour rows, and wide rounds (several streams, long copy windows) favour the tensor units. Switching per round would break drafted against"draft": false, because the two kernels add in different orders. That is why this is opt-in.rt/QUALITY.md, chat mode) passes: 39 of 40 exact answers on both, the same miss, the same 64K needle result on both (raw-completion needle, a one-token stop with the same hash on both). Greedy agreement is 16 of 64, reported only.zig build test-nativepasses on the M5 Ultra.Docs: a
TF_FLASHNEXT_M5_ROWSrow indocs/environment.md(andTF_FLASHNEXT_GROUPED_ROWSnow says where it applies), a known-issues line on the token difference, and a changelog line.Next: a tensor-unit decode kernel that adds in the row kernels' order. Narrow rounds could then take rows and wide ones the tensor units with the same bits, and M5 would be faster by default at every width.