Extend regular NAX tuning to gen-17 g devices#3295
Open
lentil32 wants to merge 1 commit intoml-explore:mainfrom
Open
Extend regular NAX tuning to gen-17 g devices#3295lentil32 wants to merge 1 commit intoml-explore:mainfrom
lentil32 wants to merge 1 commit intoml-explore:mainfrom
Conversation
521be5c to
ebc1ab4
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.
Proposed changes
mlx/backend/metal/matmul.cppwhile preserving the existing tuneds/c/dpath.64x128x(64|256), wm=2, wn=4, swizzle=2route to M5-generationgdevices forfloat16/bfloat16, which is the path relevant to NA/M5 addmm / matmul on MPS ~10–20% slower than PyTorch for 1280×1280 BF16 (hurts Nano Chat training) #3196.This may address #3196 on M5 devices that route through the
gregular NAX path.Benchmarks
Measured manually on an Apple M5 Pro with the issue-shaped BF16
1280x1280addmm/matmulmicrobenchmark (30warmup iterations,1000timed iterations), using explicit BF16 flags.This machine reports
architecture = applegpu_g17s, so the real-device path is effectively unchanged because it already takes the existing tuned route:addmm:0.3073 ms -> 0.3059 ms(-0.5%)matmul:0.3108 ms -> 0.3099 ms(-0.3%)To validate the new
groute directly, I reran the same workload withMLX_METAL_GPU_ARCH=applegpu_g17g:addmm:0.3620 ms -> 0.3132 ms(-13.5%,1.16x faster)matmul:0.3495 ms -> 0.3208 ms(-8.2%,1.09x faster)These results suggest the change improves the targeted
gpath, but I have not yet validated it on a real device that reportsapplegpu_g17g.Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes