Repository navigation
Flash Next on M5: kept DeltaNet states and half nibbles, 6.5% faster decode, same tokens - #3271
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/m5-kept-nibbles
branch
2 times, most recently
from
November 19, 2026 01:51
67bc418 to
338ce88
Compare
This was referenced Nov 19, 2026
Two choices M1-M4 already make were switched off on GPUs with tensor units: - keepStates and keepLoneStates returned early on tensorUnits(), so an M5 wrote every window row's DeltaNet state each round and then copied the kept one, instead of keeping one state a layer and replaying the kept rows. - rows_w.nib gave generation 17 the plain converts, so the 4/32 expert, dense row and hyper-connection kernels converted each code to float one at a time instead of two a half operation. Both now apply on M5 as on M3 and M4. M1 and M2 keep the exponent trick. Replies are unchanged. On an M5 Ultra (Qwen3.8-Flash-Next MLX 4-bit MTP, one stream, 16 prompts of 512 tokens, main/new/new/main): - greedy 206.4 -> 220.2 tok/s (+6.6%), sampled 184.5 -> 196.6 (+6.5%), "draft": false 109.1 -> 111.3 (+2.0%), no prompt slower - tokens equal to main on 32 of 32 replies; drafted == "draft": false 16 of 16 - --parallel 4, distinct prompts staggered: every concurrent reply equals its solo run; sampled 1/2/4 streams +5.0/+4.7/+0.8%, greedy +7.2/+3.5/+4.9% zig build test-native passes on an M5 Max; lean 0 new.
ashhart
force-pushed
the
lead/m5-kept-nibbles
branch
from
November 20, 2026 10:12
338ce88 to
dd3eb30
Compare
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.
Two decode choices that M1-M4 already make were switched off on Macs with tensor units (M5). This turns them on there too. Replies are unchanged, and one stream is about 6.5% faster on main's default M5 path.
keepStatesandkeepLoneStates(engine_rounds.zig) returned early ontensorUnits(). An M5 therefore wrote every window row's DeltaNet state each round and then copied the kept one. Now it keeps one state per layer and replays the kept rows, as M1-M4 have since October.rows_w.nibgave generation 17 the plain converts, so the 4/32 expert, dense-row and hyper-connection kernels converted each code to float one at a time. Now M5 takes the half path that M3 and M4 use, two codes per half operation with the same values in the same order. M1 and M2 keep the exponent trick.Measured on an M5 Ultra (512 GB), Qwen3.8-Flash-Next MLX 4-bit MTP at 2b170fa6, one server per arm, main/new/new/main, 16 prompts (
tools/bench_prompts.json) of 512 tokens:"draft": false, mean tok/s"draft": falseon 16 of 16.--parallel 4with distinct prompts staggered 150 ms (bench_concurrent.py --alone), every concurrent reply equals its solo run. Totals at 1, 2 and 4 streams: sampled +5.0 / +4.7 / +0.8%, greedy +7.2 / +3.5 / +4.9%.TF_FLASHNEXT_M5_ROWS=1) on top, the same 16 prompts go from 238.8 to 254.1 greedy (+6.4%) and from 215.6 to 229.2 sampled (+6.3%), tokens equal on 32 of 32. The two changes don't touch the same files.zig build test-nativepasses on an M5 Max, and lean reports no new problems. The changelog line goes under a new## Unreleased, since main is at the 1.2.8 release commit.