Conversation
nastya236
marked this pull request as ready for review
September 8, 2026 13:39
zcbenz
reviewed
Sep 11, 2026
| const array& offsets, | ||
| array& out, | ||
| cu::CommandEncoder& encoder) { | ||
| #if CUDNN_VERSION >= 91800 |
Member
There was a problem hiding this comment.
We don't need to check CUDNN_VERSION ourselves, the cudnn-frontend C++ APIs we use are capable of detecting cudnn version and throw errors. And we can ensure minimum cudnn version in setup.py by setting the version of nvidia-cudnn-cu12/13 dependencies.
Also since cudnn_grouped_mm requires sm80 and later, this function should check it here.
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.
Currently for
grouped_mmoperation (that is used in MoEs for example) we use thegather_mmwith sorted indices. On cuda it is cutlass unaligned kernel for sm80 (Ampere). Also, sincegather_mmexpects indices as input (not token counts), in case of MoEs swiglu we need to recompute tokens offset in all projections.This PR adds:
grouped_mmop that inputs sorted activations, token offsets and experts weightsGroupedMMprimitive [for now only forward]Before: gather_mm=47.922ms
After: grouped_mm=0.552ms
I hope that the numbers are correct, I recomputed it multiple times. 80x difference looks weird tho..
TODO:
Currently tests for grouped_mm are skipped because sm 7.5 is not supported by cudnn.
I decided to split the change in two pull requests: this one implements cudnn port, primitive and operation.
The second one will implement a fallback for sm < 80 using
cutlass_grouped_mm.After this we can train MoEs with mlx 🎉