Skip to content

[Model] Let Qwen3MoeDecoderLayer take the MoE block type - #58859

Open
cr-gao wants to merge 1 commit into
vllm-project:mainfrom
cr-gao:feat/qwen3-moe-block-type
Open

cr-gao wants to merge 1 commit into
vllm-project:mainfrom
cr-gao:feat/qwen3-moe-block-type

Conversation

@cr-gao

@cr-gao cr-gao commented Sep 26, 2026

Copy link
Copy Markdown

Purpose

Qwen3MoeDecoderLayer builds its sparse MoE block with a hard-coded Qwen3MoeSparseMoeBlock(...), while the model level already lets callers inject decoder_layer_type. A downstream layer subclass that only needs a different MoE block forward today has to either re-implement the whole __init__ (as MellumDecoderLayer does for attention) or reassign self.mlp.__class__ after construction to keep the loaded experts.

This adds moe_block_type: type[nn.Module] = Qwen3MoeSparseMoeBlock to the layer constructor, mirroring decoder_layer_type. Default behaviour is unchanged.

Downstream use: vLLM-Omni's opt-in HF-numerics mode for the Qwen3-Omni thinker (true on-policy RL, verl-project/verl-omni#637), which subclasses the layer and the MoE block.

Test Plan

No behaviour change for existing callers: the default argument is the class that was hard-coded. pre-commit run --files vllm/model_executor/models/qwen3_moe.py.

Test Result

ruff / ruff format clean. Qwen3-MoE model construction and weight loading exercised downstream through the vLLM-Omni subclass on a 4-layer Qwen3-Omni-30B-A3B thinker.

AI assistance was used for this change. I reviewed every line.

Signed-off-by: cr-gao <gaochenrui@sjtu.edu.cn>

@claude claude 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.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run for upstream CI or /amd-ci run for AMD CI only whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use the corresponding /ci run, /ci retry, and /ci cancel commands, or their /amd-ci variants. New commits do not start upstream CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@mergify

mergify Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

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

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 Oct 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase qwen Related to Qwen models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant