Adding support for fused_moe_gmm#3627
Merged
copybara-service[bot] merged 1 commit intomainfrom Apr 21, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
4a22680 to
814348f
Compare
RissyRan
reviewed
Apr 9, 2026
Collaborator
RissyRan
left a comment
There was a problem hiding this comment.
Overall LGTM. Could you add your tests to showcase the functionality? Thanks!
e2a24f7 to
b5d61be
Compare
gobbleturk
reviewed
Apr 10, 2026
gobbleturk
reviewed
Apr 10, 2026
gobbleturk
reviewed
Apr 10, 2026
gobbleturk
reviewed
Apr 10, 2026
gobbleturk
reviewed
Apr 10, 2026
b5d61be to
a6cfd99
Compare
NuojCheng
reviewed
Apr 13, 2026
57d1a60 to
be95bcf
Compare
NuojCheng
reviewed
Apr 14, 2026
NuojCheng
reviewed
Apr 14, 2026
be95bcf to
611c5bc
Compare
611c5bc to
d0a0744
Compare
6 tasks
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.
Description
This PR adds support for the
tpu-inferecefused_moe_gmmkernel in the MaxText MoE inference codepath. Initial results using this kernel show up to ~4x generation throughput increase when testing withqwen3-30b-a3b.Additionally, this PR introduces a second optimization to MaxText which pre-fuses the MoE weight kernels such that they can be efficiently passed into the
fused_moe_gmmkernel. We show the impact of these optimizations below with autoregressive generation step times:Baseline (MaxText
sparse_matmulMoE): 28.353 msFused MoE (prefuse_moe_weights=False): 20.432 ms
Fused MoE (prefuse_moe_weights=True): 6.114 ms
Tests
This PR adds new tests to
tests/unit/moe_test.py. Additionally this PR was tested e2e with both qwen3-30b-a3b and qwen3-235b-a22b.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.