Skip to content

[Refactor] [MoE] Rename moe-related classes & files#3646

Merged
wangxiyuan merged 1 commit intovllm-project:mainfrom
Pr0Wh1teGivee:new_finalize_moe
Oct 25, 2025
Merged

[Refactor] [MoE] Rename moe-related classes & files#3646
wangxiyuan merged 1 commit intovllm-project:mainfrom
Pr0Wh1teGivee:new_finalize_moe

Conversation

@Pr0Wh1teGivee
Copy link
Copy Markdown
Contributor

@Pr0Wh1teGivee Pr0Wh1teGivee commented Oct 23, 2025

What this PR does / why we need it?

  1. Rename common_fused_moe.py to fused_moe.py.
  2. Rename fused_moe_prepare_and_finalize.py / FusedMoEPrepareAndFinalize to prepare_finalize.py / PrepareAndFinalize.
  3. Rename vllm_ascend/ops/moe to vllm_ascend/ops/fused_moe.
  4. Move vllm_ascend/ops/fused_moe.py to vllm_ascend/ops/fused_moe/fused_moe.py

Does this PR introduce any user-facing change?

No

How was this patch tested?

e2e & ut

@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

Copy link
Copy Markdown
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 is a refactoring effort to rename and restructure Mixture-of-Experts (MoE) related files. The changes are largely consistent with this goal, involving file moves and import path updates. However, I've identified a systematic error in the new import paths across several files. It appears a refactoring script may have incorrectly added an extra .fused_moe segment to many import paths, which will lead to ImportError exceptions and break the build. I have provided critical comments with suggestions to correct these paths. Apart from these import issues, the refactoring appears to be in good order.

Comment on lines +39 to +40
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.fused_moe.moe_comm_method import setup_moe_comm_method
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The import paths for experts_selector and moe_comm_method are incorrect. The file vllm_ascend/ops/fused_moe/fused_moe.py is not a package, so you cannot import from it. The extra .fused_moe in the path should be removed.

Suggested change
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.fused_moe.moe_comm_method import setup_moe_comm_method
from vllm_ascend.ops.fused_moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.moe_comm_method import setup_moe_comm_method

Comment on lines 27 to 35
from vllm_ascend.ops.fused_moe.fused_moe.prepare_finalize import (
PrepareAndFinalizeWithAll2All,
PrepareAndFinalizeWithAllGather, PrepareAndFinalizeWithMC2,
PrepareAndFinalizeWithNaiveMulticast)
from vllm_ascend.ops.fused_moe.fused_moe.moe_mlp import unified_apply_mlp
from vllm_ascend.ops.fused_moe.fused_moe.token_dispatcher import (TokenDispatcherWithAll2AllV,
TokenDispatcherWithAllGather,
TokenDispatcherWithMC2,
TokenDispatcherWithMoge)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The import paths for prepare_finalize, moe_mlp, and token_dispatcher are incorrect. The file vllm_ascend/ops/fused_moe/fused_moe.py is not a package, so you cannot import from it. The extra .fused_moe in the import paths should be removed.

Suggested change
from vllm_ascend.ops.fused_moe.fused_moe.prepare_finalize import (
PrepareAndFinalizeWithAll2All,
PrepareAndFinalizeWithAllGather, PrepareAndFinalizeWithMC2,
PrepareAndFinalizeWithNaiveMulticast)
from vllm_ascend.ops.fused_moe.fused_moe.moe_mlp import unified_apply_mlp
from vllm_ascend.ops.fused_moe.fused_moe.token_dispatcher import (TokenDispatcherWithAll2AllV,
TokenDispatcherWithAllGather,
TokenDispatcherWithMC2,
TokenDispatcherWithMoge)
from vllm_ascend.ops.fused_moe.prepare_finalize import (
PrepareAndFinalizeWithAll2All,
PrepareAndFinalizeWithAllGather, PrepareAndFinalizeWithMC2,
PrepareAndFinalizeWithNaiveMulticast)
from vllm_ascend.ops.fused_moe.moe_mlp import unified_apply_mlp
from vllm_ascend.ops.fused_moe.token_dispatcher import (TokenDispatcherWithAll2AllV,
TokenDispatcherWithAllGather,
TokenDispatcherWithMC2,
TokenDispatcherWithMoge)

Comment on lines 31 to 32
from vllm_ascend.ops.fused_moe.fused_moe.comm_utils import (
async_all_to_all, gather_from_sequence_parallel_region)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The import path for comm_utils is incorrect. The file vllm_ascend/ops/fused_moe/fused_moe.py is not a package, so you cannot import from it. The extra .fused_moe in the path should be removed.

Suggested change
from vllm_ascend.ops.fused_moe.fused_moe.comm_utils import (
async_all_to_all, gather_from_sequence_parallel_region)
from vllm_ascend.ops.fused_moe.comm_utils import (
async_all_to_all, gather_from_sequence_parallel_region)

from vllm_ascend.ascend_config import get_ascend_config
from vllm_ascend.distributed.parallel_state import get_mc2_group
from vllm_ascend.ops.moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The import path for experts_selector is incorrect. The file vllm_ascend/ops/fused_moe/fused_moe.py is not a package, so you cannot import from it. The extra .fused_moe in the path should be removed.

Suggested change
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.experts_selector import select_experts


from vllm_ascend.attention.attention_v1 import AscendAttentionState
from vllm_ascend.ops.moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The import path for experts_selector is incorrect. The file vllm_ascend/ops/fused_moe/fused_moe.py is not a package, so you cannot import from it. The extra .fused_moe in the path should be removed.

Suggested change
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.experts_selector import select_experts

from vllm_ascend.ascend_config import get_ascend_config
from vllm_ascend.distributed.parallel_state import get_mc2_group
from vllm_ascend.ops.moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The import path for experts_selector is incorrect. The file vllm_ascend/ops/fused_moe/fused_moe.py is not a package, so you cannot import from it. The extra .fused_moe in the path should be removed.

Suggested change
from vllm_ascend.ops.fused_moe.fused_moe.experts_selector import select_experts
from vllm_ascend.ops.fused_moe.experts_selector import select_experts

forward_context = get_forward_context()

from vllm_ascend.ops.moe.moe_comm_method import get_moe_comm_method
from vllm_ascend.ops.fused_moe.fused_moe.moe_comm_method import get_moe_comm_method
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The import path for moe_comm_method is incorrect. The file vllm_ascend/ops/fused_moe/fused_moe.py is not a package, so you cannot import from it. The extra .fused_moe in the path should be removed.

Suggested change
from vllm_ascend.ops.fused_moe.fused_moe.moe_comm_method import get_moe_comm_method
from vllm_ascend.ops.fused_moe.moe_comm_method import get_moe_comm_method

@Pr0Wh1teGivee Pr0Wh1teGivee force-pushed the new_finalize_moe branch 2 times, most recently from ad23123 to eb5a40b Compare October 23, 2025 03:36
@Pr0Wh1teGivee Pr0Wh1teGivee changed the title [Refactor] [MoE] Rename moe-related files [Refactor] [MoE] Rename moe-related classes & files Oct 23, 2025
@weijinqian0 weijinqian0 added the ready-for-test start test by label for PR label Oct 23, 2025
@weijinqian0 weijinqian0 added module:tests ready-for-test start test by label for PR ready read for review and removed module:tests ready-for-test start test by label for PR ready read for review labels Oct 23, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Signed-off-by: Pr0Wh1teGivee <calvin_zhu0210@outlook.com>
@wangxiyuan wangxiyuan merged commit 63c363d into vllm-project:main Oct 25, 2025
28 checks passed
luolun pushed a commit to luolun/vllm-ascend that referenced this pull request Nov 19, 2025
### What this PR does / why we need it?
1. Rename common_fused_moe.py to fused_moe.py.
2. Rename fused_moe_prepare_and_finalize.py / FusedMoEPrepareAndFinalize
to prepare_finalize.py / PrepareAndFinalize.
3. Rename vllm_ascend/ops/moe to vllm_ascend/ops/fused_moe.
4. Move vllm_ascend/ops/fused_moe.py to
vllm_ascend/ops/fused_moe/fused_moe.py
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
e2e & ut

- vLLM version: v0.11.0rc3
- vLLM main:
vllm-project/vllm@17c540a

Signed-off-by: Pr0Wh1teGivee <calvin_zhu0210@outlook.com>
Signed-off-by: luolun <luolun1995@cmbchina.com>
hwhaokun pushed a commit to hwhaokun/vllm-ascend that referenced this pull request Nov 19, 2025
### What this PR does / why we need it?
1. Rename common_fused_moe.py to fused_moe.py.
2. Rename fused_moe_prepare_and_finalize.py / FusedMoEPrepareAndFinalize
to prepare_finalize.py / PrepareAndFinalize.
3. Rename vllm_ascend/ops/moe to vllm_ascend/ops/fused_moe.
4. Move vllm_ascend/ops/fused_moe.py to
vllm_ascend/ops/fused_moe/fused_moe.py
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
e2e & ut

- vLLM version: v0.11.0rc3
- vLLM main:
vllm-project/vllm@17c540a

Signed-off-by: Pr0Wh1teGivee <calvin_zhu0210@outlook.com>
Signed-off-by: hwhaokun <haokun0405@163.com>
NSDie pushed a commit to NSDie/vllm-ascend that referenced this pull request Nov 24, 2025
### What this PR does / why we need it?
1. Rename common_fused_moe.py to fused_moe.py.
2. Rename fused_moe_prepare_and_finalize.py / FusedMoEPrepareAndFinalize
to prepare_finalize.py / PrepareAndFinalize.
3. Rename vllm_ascend/ops/moe to vllm_ascend/ops/fused_moe.
4. Move vllm_ascend/ops/fused_moe.py to
vllm_ascend/ops/fused_moe/fused_moe.py
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
e2e & ut

- vLLM version: v0.11.0rc3
- vLLM main:
vllm-project/vllm@17c540a

Signed-off-by: Pr0Wh1teGivee <calvin_zhu0210@outlook.com>
Signed-off-by: nsdie <yeyifan@huawei.com>
Clorist33 pushed a commit to Clorist33/vllm-ascend that referenced this pull request Dec 10, 2025
### What this PR does / why we need it?
1. Rename common_fused_moe.py to fused_moe.py.
2. Rename fused_moe_prepare_and_finalize.py / FusedMoEPrepareAndFinalize
to prepare_finalize.py / PrepareAndFinalize.
3. Rename vllm_ascend/ops/moe to vllm_ascend/ops/fused_moe.
4. Move vllm_ascend/ops/fused_moe.py to
vllm_ascend/ops/fused_moe/fused_moe.py
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
e2e & ut

- vLLM version: v0.11.0rc3
- vLLM main:
vllm-project/vllm@17c540a

Signed-off-by: Pr0Wh1teGivee <calvin_zhu0210@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants