Skip to content

Enable mask for AdamW optimizer#3280

Merged
copybara-service[bot] merged 1 commit intomainfrom
weight_decay
Mar 3, 2026
Merged

Enable mask for AdamW optimizer#3280
copybara-service[bot] merged 1 commit intomainfrom
weight_decay

Conversation

@RissyRan
Copy link
Copy Markdown
Collaborator

@RissyRan RissyRan commented Feb 28, 2026

Description

Enable mask for AdamW optimizer

  • Add mask option for AdamW optimizer
  • Rename muon_test as optimizers_test, and add unit tests for mask generation

Tests

  • Add unit tests accordingly
  • Expect all github runners are green

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@github-actions
Copy link
Copy Markdown

🤖 Hi @RissyRan, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

## 📋 Review Summary

This Pull Request introduces a mechanism to exclude specific parameters from AdamW weight decay based on regular expression patterns defined in the configuration. The implementation is well-tested and neatly integrated into get_optimizer and the custom adam_pax optimizer.

🔍 General Feedback

  • The logic accurately matches the optax API expectations for optimizer masks.
  • I've left a small optimization suggestion to pre-compile the regular expressions during mask initialization, which will improve the tracing time and fail fast on invalid patterns.

Comment thread src/maxtext/optimizers/optimizers.py
Comment thread tests/unit/optimizers_test.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 28, 2026

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/optimizers/optimizers.py 73.33% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@gagika gagika left a comment

Choose a reason for hiding this comment

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

looks good 2 minor comments:

Comment thread src/maxtext/optimizers/optimizers.py Outdated
Comment thread src/maxtext/configs/base.yml Outdated
Copy link
Copy Markdown
Collaborator

@gagika gagika left a comment

Choose a reason for hiding this comment

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

thanks

@copybara-service copybara-service Bot merged commit e091675 into main Mar 3, 2026
62 of 66 checks passed
@copybara-service copybara-service Bot deleted the weight_decay branch March 3, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants