Repository navigation
metal row projection: windows of 4+ rows run 8 at a time, then 4, 2 and 1, each code unpacked once - #3129
Merged
Conversation
7 of 8 tasks
Owner
Author
|
Device run on an M3 Ultra (pre-M5), main against this head, Qwen3.8-27B: REVIEW. Decode at a 16,384-token context is slower, 28.4 to 27.4 tok/s (-3.5%), with both new runs (27.33, 27.55) below both base runs (28.45, 28.39). It's held out of the landing queue until the pre-M5 path is level, perhaps by keeping the 8-row step to M5, where it was measured.
|
ashhart
force-pushed
the
lead/metal-rows-8
branch
from
November 14, 2026 07:22
577720b to
f38ad75
Compare
…nd 1, each code unpacked once
… M1-M4 keep main's 4, 2 and 1 On an M3 Ultra, decode at a 16,384-token context was 3.5% slower with the 8-row step (28.4 to 27.4 tok/s, both new runs below both base runs); it was measured only on an M5 Ultra. Pipelines.load now records device.tensorUnits(), the chip fact the Qwen3.8-27B Metal code already reads (applegpu_g17 and later), and call and callStrided take the wide pipelines only when it is set. Without tensor units every row count keeps main's pipelines, so M1-M4 run main's kernels and steps exactly. A host test pins that dispatch for every width, both sums and 1 to 32 rows; the existing dispatch test now covers the tensor-unit side.
On Linux the Metal Pipeline is an inert stand-in without an id field, so the two tests that build pipelines by id failed to compile in test-gemma4-owners-host once that step reached this file. They now skip at comptime off macOS.
ashhart
force-pushed
the
lead/metal-rows-8
branch
from
November 17, 2026 07:06
996146f to
01d94d6
Compare
1 task done
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.
Metal row projections ran windows of more than four rows four at a time, unpacking each weight code once a group. Windows of 4 or more rows now run 8 at a time, then 4, 2 and 1 (6 rows run 4+2, 7 run 4+2+1, 15 run 8+4+2+1), so each code is unpacked once for up to eight rows. Each row's sum keeps the same order of terms, so results stay bit-equal to one row alone. The new template parameter defaults off, so GLM, MiniMax, LFM3 and qwen27 keep their current code.
Tests:
row_projection.zig10/10 (the dispatch test fails with main's dispatch);test-kernel-contract203/203 with the new records test; the shader compiles at metal3.1 and metal4.1 with all 36 new symbols, and its includers compile.Device check pending, on an M5 and an M1-M4 Mac:
tf-row-widths-checkagainst main's shader (widths 1-32 bit-equal to one row alone, width 16 byte-equal to main's kernel); therow projection wideandrow projectionkernel-contract entries (42 kernels pass, all 36 controls red); a served A/B with token hashes equal to main at T=0 and tok/s no lower (holding 8 rows a thread may cost registers on M1-M4).