Skip to content

Small refactor of gmm in moe.py#3605

Merged
copybara-service[bot] merged 1 commit intomainfrom
mattdavidow-gmm-clean-a1
Apr 10, 2026
Merged

Small refactor of gmm in moe.py#3605
copybara-service[bot] merged 1 commit intomainfrom
mattdavidow-gmm-clean-a1

Conversation

@gobbleturk
Copy link
Copy Markdown
Collaborator

@gobbleturk gobbleturk commented Apr 8, 2026

Description

Small refactor to help aide in code readability/maintainability following go/small-functions

I should probably have used an agent for this, but manually doing this has forced me to learn our code. Understanding is the way!

Tests

Identical performance before/after (pure refactor)

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 68.08511% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/moe.py 62.50% 11 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@NuojCheng NuojCheng left a comment

Choose a reason for hiding this comment

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

Lets goooo

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

🤖 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

🤖 I'm sorry @RissyRan, but I was unable to process your request. Please see the logs for more details.

Copy link
Copy Markdown
Collaborator

@RissyRan RissyRan left a comment

Choose a reason for hiding this comment

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

Thanks!

group_sizes,
max_utils.generate_representative_group_sizes(inputs.shape[0], kernel.shape[0]),
)
pad_length = self.config.wi_tile_fwd_batch_seq
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are those padding also considered in the refactor? I didn't find them.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

@richjames0 richjames0 left a comment

Choose a reason for hiding this comment

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

lgtm pending ran's comment

@gobbleturk gobbleturk force-pushed the mattdavidow-gmm-clean-a1 branch from 8c18ad4 to feb61fc Compare April 10, 2026 17:45
@copybara-service copybara-service bot merged commit 46dbaf5 into main Apr 10, 2026
37 checks passed
@copybara-service copybara-service bot deleted the mattdavidow-gmm-clean-a1 branch April 10, 2026 19:02
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