Repository navigation
Metal: the 27B's 8-bit lane path reads its code bytes directly and reuses producer sums (fixes #2502) - #2518
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/q8-lane-direct
branch
3 times, most recently
from
November 8, 2026 07:11
8c86207 to
0994248
Compare
Exercise the head and fused attention, recurrent and MLP widths at the checkpoint’s K splits before replacing the staged byte reader. Keep the same FP64 bounds, nonfinite rules, guards and sum stress.
Use a device uint8 tensor for stored codes and accept the producer’s ordered group-64 sums. Keep the original 16-row windows, K splits and FP32 arithmetic. Four-bit compiled AIR and model state remain identical. The pinned shader’s byte contract covers BF16 and FP32 outputs, fallback sums and group variants, with wrong-group and wrong-stride controls. Cold 2K and 8K prompts improve 18.5% and 18.2% on an M5 Ultra. Document the remaining dense projection gap against 4-bit. Refs #2502
ashhart
force-pushed
the
lead/q8-lane-direct
branch
from
November 8, 2026 08:08
0994248 to
b5e6295
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.
Fixes #2502. On M5, an MLX 8-bit group-64 Qwen3.8-27B ran every projection through
tf_lane's staged branch. That branch copied each code byte through threadgroup memory, an identity for 8-bit, and recomputed every group's input sum in every 32-column tile, although the producer kernels had already written those sums.What changes, for
TF_BITS == 8only:uint8device view of the stored code tiles replaces the staged copy (zig/kernels/metal/core/lane_projection.metal).encodeSums, and the register path is unchanged.Exactness, pinned first: the first commit adds
lane q8 g64contract entries for the 27B's head, attention, recurrent and MLP dimensions at SK1/2/4/8, and passes them on the untouched shader. A frozen copy of main's shader then serves as the byte reference. Every output byte of the new path equals it across:Two planted controls go red at gate 3: a byte view one group off, and sums read at the wrong stride. The 24 launch records pass, and the 4-bit pipelines are byte-identical, with 24 AIR pairs.
Measured on an M5 Ultra, with fresh processes in the order warm, main, new, new, main, one stream and no drafts. Tokens and committed prompt state are byte-equal to main.
The 8-bit prompt is still 40–41% of 4-bit's, against a stored-weight byte ratio of 54.4%. Dense projections dominate its profile, so the 4-bit register kernel's structure is the next lever there. The 27B recipe now has one 8-bit table: these numbers, plus the disk and wired memory from #2506.
Lean shows nothing new, and every file is at or under 600 lines.