Skip to content

Gemma 4#175

Open
SamuelMarks wants to merge 1 commit into
jax-ml:mainfrom
SamuelMarks:gemma4
Open

Gemma 4#175
SamuelMarks wants to merge 1 commit into
jax-ml:mainfrom
SamuelMarks:gemma4

Conversation

@SamuelMarks

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds Gemma 4

Checklist

  • I have read the Contribution Guidelines and used pre-commit hooks to format and squash so that this PR has 1 commit typically.
  • I have added all the necessary unit tests for my change (run_model.py, test_outputs.py, and/or model_validation_colab.ipynb).
  • (Code Quality) I have reviewed the code and removed all superfluous comments or LLM-generated boilerplate. Only functional, necessary code remains.
  • I have signed the Contributor License Agreement (CLA).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Gemma 4 model architecture, featuring a hybrid Mixture of Experts (MoE) and a cycle of local sliding window and global attention layers. The implementation includes specialized RMSNorm, SwiGLU MLPs, and sharding configurations for FSDP and TP. Feedback indicates that the sliding_window_size is not yet utilized in the attention mechanism and that the MoE implementation should be optimized to avoid inefficient Python loops. Additionally, there are suggestions to fix a missing import in the sharding tests and to clean up imports in the modeling file.

Comment thread bonsai/models/gemma4/modeling.py Outdated
Comment thread bonsai/models/gemma4/tests/test_sharding_gemma4.py Outdated
Comment thread bonsai/models/gemma4/modeling.py Outdated
Comment thread bonsai/models/gemma4/modeling.py Outdated
Comment thread bonsai/models/gemma4/modeling.py Outdated
@SamuelMarks SamuelMarks marked this pull request as draft April 29, 2026 20:56
@SamuelMarks SamuelMarks marked this pull request as ready for review April 30, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant