Skip to content

[Refactor] Replace activation: str with MoEActivation enum#33843

Merged
vllm-bot merged 15 commits intovllm-project:mainfrom
neuralmagic:moe-activation-enum
Feb 12, 2026
Merged

[Refactor] Replace activation: str with MoEActivation enum#33843
vllm-bot merged 15 commits intovllm-project:mainfrom
neuralmagic:moe-activation-enum

Conversation

@mgoin
Copy link
Member

@mgoin mgoin commented Feb 4, 2026

Purpose

We have had activation defined, validated, and passed around as a raw string forever. Now that we have popular models that don't just use the silu default and also need to support non-gated MoEs and their activation functions, we need to have a single source of truth for all the activation functions that exist in vLLM and which MoE kernels support which functions. I want to start with MoE since that is where we have the most divergence in support due to fused kernels.

This PR introduces MoEActivation and aims to replace all usage of activation: str in internal interfaces for MoE. Note that we do keep FusedMoE.__init__ as activation: str in order to avoid changes to the model definitions, however we do validate it with MoEActivation.from_str(activation) within the constructor.

We do still need to keep activation: str in some function signatures to be compatible with torch's custom op registration so we will pass in the MoEActivation as activation.value and convert it back within the custom op with MoEActivation.from_str(activation)

Test Plan

Test Result

Run all tests in CI and discuss with external hardware plugins


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: mgoin <mgoin64@gmail.com>
Copy link
Contributor

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

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 a great refactoring by defining a MoEActivation enum to replace string-based activation function identifiers. This significantly improves type safety and code clarity across the MoE-related modules. The changes are extensive and have been applied consistently throughout the codebase. I have one piece of feedback regarding a potentially unsafe in-place modification in the new activation utility function.

@mergify
Copy link

mergify bot commented Feb 4, 2026

Hi @mgoin, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

@robertgshaw2-redhat
Copy link
Collaborator

labor of love

Signed-off-by: mgoin <mgoin64@gmail.com>
@mergify
Copy link

mergify bot commented Feb 5, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @mgoin.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Feb 5, 2026
Signed-off-by: Michael Goin <mgoin64@gmail.com>
@mergify mergify bot removed the needs-rebase label Feb 5, 2026
@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 5, 2026
@mgoin mgoin changed the title [Refactor] Define MoEActivation enum [Refactor] Replace activation: str with MoEActivation enum Feb 5, 2026
mgoin added 2 commits February 5, 2026 22:11
Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: mgoin <mgoin64@gmail.com>
@mergify
Copy link

mergify bot commented Feb 6, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @mgoin.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Feb 6, 2026
@bnellnm
Copy link
Collaborator

bnellnm commented Feb 7, 2026

Nice refactor. I added a few comments/questions.

Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: mgoin <mgoin64@gmail.com>
Copy link
Collaborator

@bnellnm bnellnm left a comment

Choose a reason for hiding this comment

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

Nice!

@vllm-bot vllm-bot merged commit ff1f83b into vllm-project:main Feb 12, 2026
139 of 147 checks passed
@github-project-automation github-project-automation bot moved this to Done in NVIDIA Feb 12, 2026
@github-project-automation github-project-automation bot moved this from Todo to Done in AMD Feb 12, 2026
@github-project-automation github-project-automation bot moved this from To Triage to Done in gpt-oss Issues & Enhancements Feb 12, 2026
warichet pushed a commit to warichet/vllm that referenced this pull request Feb 12, 2026
…project#33843)

Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: Michael Goin <mgoin64@gmail.com>
QiliangCui added a commit to vllm-project/tpu-inference that referenced this pull request Feb 13, 2026
Signed-off-by: Qiliang Cui <derrhein@gmail.com>
eldarkurtic pushed a commit to eldarkurtic/vllm that referenced this pull request Feb 19, 2026
…project#33843)

Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: Michael Goin <mgoin64@gmail.com>
Signed-off-by: Eldar Kurtic <research@neuralmagic.com>
llsj14 pushed a commit to llsj14/vllm that referenced this pull request Mar 1, 2026
…project#33843)

Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: Michael Goin <mgoin64@gmail.com>
@jikunshang jikunshang mentioned this pull request Mar 2, 2026
5 tasks
tunglinwood pushed a commit to tunglinwood/vllm that referenced this pull request Mar 4, 2026
…project#33843)

Signed-off-by: mgoin <mgoin64@gmail.com>
Signed-off-by: Michael Goin <mgoin64@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cpu Related to CPU backends gpt-oss Related to GPT-OSS models nvidia performance Performance-related issues ready ONLY add when PR is ready to merge/full CI is needed ready-run-all-tests Trigger CI with all tests for wide-ranging PRs rocm Related to AMD ROCm

Projects

Status: Done
Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants