Onboard ragged sorting kernels from tpu inference to maxtext#3814
Draft
NuojCheng wants to merge 8 commits into
Draft
Onboard ragged sorting kernels from tpu inference to maxtext#3814NuojCheng wants to merge 8 commits into
NuojCheng wants to merge 8 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
803c1de to
4ac0bcf
Compare
4ac0bcf to
b1ce84c
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.
Description
This PR onboards two critical kernels:
ragged_gatherandragged_gather_reduce.The key difference lies in their routing and output shapes:
ragged_gather: Performs simultaneous permutation and fan-out (num_tokens x emb_dim→num_tokens x top_k x emb_dim).ragged_gather_reduce: Adds an accumulation step for fan-in (num_tokens x top_k x emb_dim→num_tokens x emb_dim).During the forward pass, we use
ragged_gatherfor dispatch andragged_gather_reducefor combine. In the backward pass, these roles are swapped.FIXES: b/496676734
Tests
We observe performance advantage when ragged sort is enabled, while also notice some regression issue between JAX==0.10.0 and 0.10.1.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.