Add support for flexible MTP layer architecture in MaxText.#3734
Draft
Add support for flexible MTP layer architecture in MaxText.#3734
Conversation
This change allows specifying a different decoder layer type for Multi-Token Prediction (MTP) blocks than the one used in the base model. - Modified `get_decoder_layers` in `decoders.py` and `nnx_decoders.py` to accept an optional `decoder_block_type` parameter. - Updated `models.py` to read `mtp_decoder_type` from config and use it to fetch the appropriate layer for MTP blocks, falling back to the base model's last layer if not specified. - Added `mtp_decoder_type` to `base.yml` and `types.py`. - Added a new unit test `FlexibleMultiTokenPredictionBlockTest` to `multi_token_prediction_test.py` to verify this behavior. Verified on TPU VM with Llama base + Gemma2 MTP and Mixtral base + Llama MTP.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
This change allows specifying a different decoder layer type for Multi-Token Prediction (MTP) blocks than the one used in the base model.
get_decoder_layersindecoders.pyandnnx_decoders.pyto accept an optionaldecoder_block_typeparameter.models.pyto readmtp_decoder_typefrom config and use it to fetch the appropriate layer for MTP blocks, falling back to the base model's last layer if not specified.mtp_decoder_typetobase.ymlandtypes.py.FlexibleMultiTokenPredictionBlockTesttomulti_token_prediction_test.pyto verify this behavior.Verified on TPU VM with Llama base + Gemma2 MTP and Mixtral base + Llama MTP.
Description
Start with a short description of what the PR does and how this is a change from
the past.
The rest of the description includes relevant details and context, examples:
If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/123456
FIXES: #123456
Notice 1: Once all tests pass, the "pull ready" label will automatically be assigned.
This label is used for administrative purposes. Please do not add it manually.
Notice 2: For external contributions, our settings currently require an approval from a MaxText maintainer to trigger CI tests.
Tests
Please describe how you tested this change, and include any instructions and/or
commands to reproduce.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.