Skip to content

Commit 17f05b1

Browse files
authored
[Feature] Add CustomQwen3MoeForCausalLM model (#925)
Tweak packed_modules_mapping to support W8A8 weights. <!-- Thanks for sending a pull request! BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing/overview.html --> ### What this PR does / why we need it? <!-- - Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. - Please clarify why the changes are needed. For instance, the use case and bug description. - Fixes # --> ### Does this PR introduce _any_ user-facing change? <!-- Note that it means *any* user-facing change including all aspects such as API, interface or other behavior changes. Documentation-only updates are not considered user-facing changes. --> ### How was this patch tested? <!-- CI passed with new added/existing test. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> Signed-off-by: Yizhou Liu <liu_yizhou@outlook.com>
1 parent df58fb8 commit 17f05b1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

vllm_ascend/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ def register_model():
2929
ModelRegistry.register_model(
3030
"DeepseekV3ForCausalLM",
3131
"vllm_ascend.models.deepseek_v2:CustomDeepseekV3ForCausalLM")
32+
33+
ModelRegistry.register_model(
34+
"Qwen3MoeForCausalLM",
35+
"vllm_ascend.models.qwen3_moe:CustomQwen3MoeForCausalLM")

vllm_ascend/models/qwen3_moe.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
2+
# Copyright 2023 The vLLM team.
3+
#
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# Adapted from vllm/model_executor/models/qwen3_moe.py
17+
# This file is a part of the vllm-ascend project.
18+
19+
from vllm.model_executor.models.qwen3_moe import Qwen3MoeForCausalLM
20+
21+
22+
class CustomQwen3MoeForCausalLM(Qwen3MoeForCausalLM):
23+
packed_modules_mapping = {
24+
"qkv_proj": [
25+
"q_proj",
26+
"k_proj",
27+
"v_proj",
28+
],
29+
"gate_up_proj": [
30+
"gate_proj",
31+
"up_proj",
32+
],
33+
"experts":
34+
["experts.0.gate_proj", "experts.0.up_proj", "experts.0.down_proj"],
35+
}

0 commit comments

Comments
 (0)