Repository navigation
[Engine] Metal: opt-in routed-expert tiles (STRATA_METAL_MOE_GU/_DN); Q2_0 8,1,2 + 4,2,4 is 17-24% faster on M1 Max - #4272
Open
joseedson18jc wants to merge 1 commit into
Conversation
…perts' tiles as an opt-in knob Both expert windows (decode and MTP) read "L,R,S" from the environment; only tiles moe.metal instantiates (GU_SET / DN_SET) are taken, anything else is refused with a log line and the default tile stays. Unset, nothing changes. M1 Max, Q2_0 pack (Qwen3.8-Flash-Next), 26 Oct 2026: - expert_parity --bench: gate/up 8,1,2 + down 4,2,4 against the default 32,1,4 + 8,1,4 cut the expert block 17-24% at 1-3 tokens (114 -> 94, 214 -> 167, 318 -> 242 us a layer); parity y rel L2 5-6e-8, PASS. - Live A/B (bracketed B C B C, on 0.1.51 + Niko1221#3301): greedy 32.7 / 34.0 -> 35.8 / 35.7 tok/s, sampled 31.1 / 32.4 -> 33.8 / 33.3. Same idea as Niko1221#4238 (M1/M2 tiles for the K quants), measured here for Q2_0.
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.
Problem and result
On the M1/M2 family the routed experts of a Q2_0 pack run with the gate/up tile 32,1,4 and the down tile 8,1,4 (the Q2_0 down is
moe_down_142). On an M1 Max these are not the fastest tiles thatmoe.metalalready instantiates.expert_parity --bench(Q2_0 gate/up + down, synthetic, M1 Max 64 GB):Live (Qwen3.8-Flash-Next Q2_0,
--spec 2+ MTP, throughserve/server.py) this is +5-7% greedy decode. This PR adds the tiles as an opt-in knob and does not change any default.Related discussion
#4238 does the same for the K quants on M1/M2 (gate/up 8,1,2) and leaves Q2_0 on the M5 tile. This is the Q2_0 counterpart, as an env knob rather than a default, because it was measured on one machine.
Approach
STRATA_METAL_MOE_GU/STRATA_METAL_MOE_DN("L,R,S") inmetal/src/engine/window.cpp, read once:moeblock andmtp_encode.gx_gu/gx_dnand the threadgroup widths follow the chosen tile, since they are computed from the same variables.GU_SET/DN_SET(the onesmoe.metalinstantiates) are accepted. Anything else is refused with a log line, and the default stays, so a typo cannot fail pipeline creation.strata metal: STRATA_METAL_MOE_GU=8,1,2).Validation
Passed:
expert_parity --gu Q2_0 --dn Q2_0 --ntok {1,2,3} --gucfg 8,1,2 --dncfg 4,2,4: y rel L2 5.3-6.3e-8, PASS (8,1,4 + 4,2,4 also passes).expert_parity --benchper config, two runs each, table above.--sweeppicks 8,1,2 / 8,1,4 for gate/up and 4,2,4 for down at every token count.fuse_parityfails onrouter_route, identically without the change (the known M1 Max routing issue)./metrics, no other traffic:main+ the commit) buildsstrataandexpert_paritywith no new warnings.Failed:
Not run:
mainunchanged.Limits