Fix: Gemma 3 & 4 Base Model and Flax Linen Decoding #4066
Open
RexBearIU wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
c54cd4c to
39955c9
Compare
4 tasks
4 tasks
39955c9 to
2eb6078
Compare
bf6986a to
c4c93a7
Compare
|
🤖 Hi @RexBearIU, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
3a983c6 to
c4c93a7
Compare
e755816 to
5c2a98d
Compare
467033c to
355c904
Compare
…NNX decoding layer KV-cache propagation
355c904 to
59ca028
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 introduces architectural configurations for Gemma3 and Gemma4, and implements critical decoding layer KV-cache propagation fixes for JAX/NNX
(
nnx_decoders.py) and Flax Linen (decoders.py) pipelines.Before this change, Flax Linen scanned blocks (
_apply_gemma3_scanned_blocksand_apply_gemma4_scanned_blocks) lacked mechanisms to propagateintermediate KV-caches across scanned layers under
nn.scan, causing end-to-end decodes to fail.Key Changes:
- Flax Linen Decoder (
src/maxtext/layers/decoders.py): Addedkv_cachesandattention_metadatapropagation across Gemma3/4 scanned blocksvia a stack/unstack mapping over
nn.scan.- JAX/NNX Decoder (
src/maxtext/layers/nnx_decoders.py): Unified dynamic KV-cache carry updates within scanned block execution.- Model Scaffolding (
gemma3.py,gemma4.py): Addedkv_cacherouting through scannable blocks and layer inputs.Tests
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.