Skip to content

Optimize top-2 expert group score computation in MoE routing. - #5124

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_975290726
Sep 3, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_975290726

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Optimize top-2 expert group score computation in MoE routing.

In DeepSeek-style expert group routing, groups of experts are selected based on the sum of their top-2 expert scores. When using jax.lax.top_k(scores_grouped, k=2) with small group sizes (such as 32 experts per group in DeepSeek-V3), XLA:TPU falls back to BitonicSortEmitter rather than SortPrefixFusion, introducing significant sort overhead and register padding.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/moe.py 77.77% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@copybara-service
copybara-service Bot force-pushed the test_975290726 branch 3 times, most recently from f5e53f7 to 95d4b67 Compare September 3, 2026 21:25
In DeepSeek-style expert group routing, groups of experts are selected based on the sum of their top-2 expert scores. When using `jax.lax.top_k(scores_grouped, k=2)` with small group sizes (such as 32 experts per group in DeepSeek-V3), XLA:TPU falls back to `BitonicSortEmitter` rather than `SortPrefixFusion`, introducing significant sort overhead and register padding.

PiperOrigin-RevId: 975986068
@copybara-service
copybara-service Bot merged commit 5033136 into main Sep 3, 2026
7 of 8 checks passed
@copybara-service
copybara-service Bot deleted the test_975290726 branch September 3, 2026 23:34
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