Repository navigation
glm metal: 8-bit routed experts read once a window by unique expert - #3631
Merged
Merged
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 17, 2026
ashhart
added a commit
that referenced
this pull request
Nov 17, 2026
At widths other than 4/64, wide.moe ran each (row, pick) slot in its own threadgroup, so a window of R rows read each routed expert once per pick and the shared expert once per row. glm_moe_rows_u runs one threadgroup a unique expert (the route's uids, members and count) with a simdgroup per pick, and the shared expert with a simdgroup per row, so their weights come from memory once for every row that picked them. Each pick's sums are the same tf_rp_rows call, so the bits are too. Windows of 2+ rows take it; one row keeps the per-pick launch. tf-glm-rows-check: by unique expert == by pick at q8, q4 and q2 for 2, 4 and 16 rows (456,192 bit-equal values).
ashhart
force-pushed
the
lead/glm-moe-unique-q8
branch
from
November 17, 2026 04:34
a142210 to
db7de11
Compare
ashhart
added a commit
that referenced
this pull request
Nov 17, 2026
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.
At widths other than 4/64,
wide.moeran each (row, pick) slot in its own threadgroup, so a drafted window of R rows read each routed expert once per pick and the shared expert once per row.What changes
glm_moe_rows_u(glm_rows.metal) runs one threadgroup a unique expert from the route'suids,umemanducount(the lists the 4/64 gathers already read), with a simdgroup per pick, and the shared expert with a simdgroup per row. A threadgroup's simdgroups read the same expert's columns together, so its weights come from memory once for every row that picked it.tf_rp_rowscallglm_moe_rowsmakes, so the bits are the same. Windows of 2+ rows take it; one row keeps the per-pick launch.wide.moetakes the route's lists as?Unique(null keeps the per-pick launch). The new kernels get contract records (32 threads a row, 512 at 16 rows).Same bits.
tf-glm-rows-checkadds by unique expert == by pick at q8, q4 and q2 for 2, 4 and 16 rows (456,192 bit-equal values); the existing checks pass.Measured on an M5 Ultra (GLM-5.3-Flash as MLX affine 8-bit/64 with its MTP layer, converted from the official FP8 checkpoint; 16 bench prompts, 512 tokens):
"draft": false)."draft": false40.2 -> 40.2.4/64 checkpoints keep the generated gathers and are unchanged.