Support specifying tokamax gmm tile sizes in MaxText#3779
Open
Support specifying tokamax gmm tile sizes in MaxText#3779
Conversation
a7c1ee2 to
da5a5c3
Compare
…of Tokamax GMM in MaxText
da5a5c3 to
7d49b8d
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 enables specifying the tile sizes for both the forward and backward passes of Tokamax GMM (
ragged_dot) in MaxText, and updates the fallback behavior when autotuning is enabled.Proposed Changes
src/maxtext/configs/types.py): Exposes a newtokamax_gmm_autotuneconfig flag to toggle Tokamax's auto-tuner for GMM.src/maxtext/layers/moe.py&src/maxtext/models/deepseek_batchsplit_fp8.py): Instead of introducing new Tokamax-specific tiling flags, this PR reuses the existingtilingtuple parameter (configured viawi_tilingandwo_tilingflags). If autotuning is disabled (tokamax_gmm_autotune=False), it passes the existingtilingconfigurations directly via a customPallasMosaicTpuRaggedDotimplementation for the Forward (gmm_tiling), Backward DLHS (gmm_rhs_transpose_tiling), and Backward DRHS (tgmm_tiling) passes.tokamax_gmm_autotune=True), the GMM implementation now uses theheuristicsfallback for autotuning cache misses.FIXES: b/506157856
Tests
Verified by manual testing on a
tpu7x-8VM using the deepseek decoder block.Custom Tiling Sizes Test
Running with
tokamax_gmm_autotune=Falseto verify that the existing base tiling configurations are correctly passed to the Tokamax GMM implementation:JAX_PLATFORMS=tpu,cpu PYTHONPATH=src python3 -m maxtext.trainers.pre_train.train \ ... \ use_tokamax_gmm=True \ tokamax_gmm_autotune=False \ wi_tile_fwd_batch_seq=128 \ wi_tile_fwd_embed_dim=128 \ wi_tile_fwd_mlp_dim=128 \ wi_tile_dlhs_batch_seq=256 \ wi_tile_dlhs_embed_dim=256 \ wi_tile_dlhs_mlp_dim=256 \ wi_tile_drhs_batch_seq=512 \ wi_tile_drhs_embed_dim=512 \ wi_tile_drhs_mlp_dim=512See details in http://b/506157856
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.