Skip to content

[Raiden Weight Sync 3/7] MoE 128-lane layout and padding for TPU GMM kernels - #5168

Merged
copybara-service[bot] merged 1 commit into
mainfrom
yixuann-m2-moe-fused-layout
Sep 10, 2026
Merged

[Raiden Weight Sync 3/7] MoE 128-lane layout and padding for TPU GMM kernels#5168
copybara-service[bot] merged 1 commit into
mainfrom
yixuann-m2-moe-fused-layout

Conversation

@YixuanWang-99

@YixuanWang-99 YixuanWang-99 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Overview

Part of the stacked Raiden weight-sync enablement PR chain replacing #5089.
Pairs with Tunix [T5] (google/tunix).

Stack:

Details

  • Implements 128-lane interleaving and padding in convert_utils.py to match TPU GMM kernel requirements (gmm_v2.py).
  • Adds compute_padded_moe_mlp_dim in convert_utils.py.
  • Adds unit tests in tests/post_training/unit/convert_utils_test.py.

Verification

  • pytest tests/post_training/unit/convert_utils_test.py (6/6 passed).

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.

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

Copy link
Copy Markdown

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 MoE padding utilities, unit tests, and compatibility shims for Tunix/tpu-inference weight sync, alongside refactoring convert_utils.py and qwen35_moe.py to support TPU GMM_v2 kernel alignment. Feedback focuses on preventing potential crashes on non-glibc systems when loading libc, avoiding abstract ShapeDtypeStruct returns when concrete arrays are present, optimizing padding logic to reduce memory overhead, validating head divisibility, and properly handling negative scan_axis indices in bounds checks.

Comment thread src/maxtext/integration/vllm/convert_utils.py Outdated
Comment thread src/maxtext/integration/vllm/convert_utils.py Outdated
Comment thread src/maxtext/integration/vllm/moe_padding.py Outdated
Comment thread src/maxtext/integration/vllm/torchax_converter/qwen35_moe.py Outdated
Comment thread src/maxtext/integration/vllm/convert_utils.py Outdated
Comment thread src/maxtext/integration/vllm/convert_utils.py Outdated
Comment thread src/maxtext/integration/vllm/convert_utils.py Outdated
Comment thread src/maxtext/integration/vllm/convert_utils.py Outdated
Comment thread src/maxtext/integration/vllm/convert_utils.py Outdated
@khatwanimohit
khatwanimohit force-pushed the yixuann-m1-raiden-unscan branch 2 times, most recently from 0172b97 to 309aade Compare September 9, 2026 21:24
@SurbhiJainUSC
SurbhiJainUSC changed the base branch from yixuann-m1-raiden-unscan to main September 9, 2026 21:39
@SurbhiJainUSC
SurbhiJainUSC force-pushed the yixuann-m2-moe-fused-layout branch 16 times, most recently from 96fecff to bd2cbd8 Compare September 9, 2026 23:13
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.66667% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/integration/vllm/convert_utils.py 54.38% 17 Missing and 9 partials ⚠️

📢 Thoughts on this report? Let us know!

- Add 128-lane interleaving and padding in convert_utils
- Remove dead scan_fused_axis parameter
- Add compute_padded_moe_mlp_dim in moe_padding
- Add unit tests for convert_utils padding and fusion
@copybara-service
copybara-service Bot merged commit 30a144c into main Sep 10, 2026
81 checks passed
@copybara-service
copybara-service Bot deleted the yixuann-m2-moe-fused-layout branch September 10, 2026 00:57
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.

6 participants