Skip to content

Add SparseCore collective offloading for MoE with custom VJP for FSDP All-Gather to Reduce-Scatter. - #5125

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_975451266
Open

Add SparseCore collective offloading for MoE with custom VJP for FSDP All-Gather to Reduce-Scatter.#5125
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_975451266

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Add SparseCore collective offloading for MoE with custom VJP for FSDP All-Gather to Reduce-Scatter.

  • Split MoE SparseCore collective offloading controls into moe_pin_sparse_core_fsdp_all_gather and moe_pin_sparse_core_ep_all_gather, while retaining moe_pin_sparse_core_all_gathers as an umbrella flag for backward compatibility.
  • Implement custom VJP _fsdp_all_gather_with_rs on MoE weights to ensure the forward pass executes All-Gather on SparseCore and the backward pass executes Reduce-Scatter on SparseCore, eliminating the backward scheduling bottleneck.
  • Automatically disable SparseCore collective offloading if the backend or target compile topology is TPU but not Gen7.
  • Add unit tests in tests/unit/moe_test.py covering flag propagation, separate flag control, non-Gen7 TPU disabling, Gen7 TPU retention, and custom VJP autodiff gradient correctness.

… All-Gather to Reduce-Scatter.

- Split MoE SparseCore collective offloading controls into `moe_pin_sparse_core_fsdp_all_gather` and `moe_pin_sparse_core_ep_all_gather`, while retaining `moe_pin_sparse_core_all_gathers` as an umbrella flag for backward compatibility.
- Implement custom VJP `_fsdp_all_gather_with_rs` on MoE weights to ensure the forward pass executes All-Gather on SparseCore and the backward pass executes Reduce-Scatter on SparseCore, eliminating the backward scheduling bottleneck.
- Automatically disable SparseCore collective offloading if the backend or target compile topology is TPU but not Gen7.
- Add unit tests in `tests/unit/moe_test.py` covering flag propagation, separate flag control, non-Gen7 TPU disabling, Gen7 TPU retention, and custom VJP autodiff gradient correctness.

PiperOrigin-RevId: 975451266
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 22.22222% with 84 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/moe.py 22.22% 81 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

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