Skip to content

Optimize MoEs for decoding using batched_mm#43126

Merged
IlyasMoutawwakil merged 15 commits intomainfrom
grouped_prefill_batched_decode
Jan 7, 2026
Merged

Optimize MoEs for decoding using batched_mm#43126
IlyasMoutawwakil merged 15 commits intomainfrom
grouped_prefill_batched_decode

Conversation

@IlyasMoutawwakil
Copy link
Member

@IlyasMoutawwakil IlyasMoutawwakil commented Jan 6, 2026

What does this PR do?

batched_mm is more performant on "smaller inputs", especially when used with torch.compile.
smaller inputs: up to 2^6-2^9 tokens depending on the num experts and num topk

crossover_plots generation benchmark

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@IlyasMoutawwakil IlyasMoutawwakil marked this pull request as ready for review January 6, 2026 14:37
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

SGTM! good that its a warning, it could be info as well !
cc @remi-or for CB we need to check perfs as well + using kernels

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

[For maintainers] Suggested jobs to run (before merge)

run-slow: deepseek_v2, ernie4_5_moe, flex_olmo, qwen2_moe

@IlyasMoutawwakil IlyasMoutawwakil merged commit 4520b54 into main Jan 7, 2026
26 checks passed
@IlyasMoutawwakil IlyasMoutawwakil deleted the grouped_prefill_batched_decode branch January 7, 2026 10:42
SangbumChoi pushed a commit to SangbumChoi/transformers that referenced this pull request Jan 23, 2026
* optimize model for decoding

* only optimize when grouped_mm

* fixes

* fix training compile failures

* no need to skip

* style

* fix

* Apply suggestion from @IlyasMoutawwakil

* Apply suggestion from @IlyasMoutawwakil

* info once
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.

3 participants