Skip to content

Commit 1a25b0a

Browse files
authored
[Test] add ut for qwen3_moe.py (vllm-project#2055)
### What this PR does / why we need it? Add ut for qwen3_moe.py ### Does this PR introduce _any_ user-facing change? No. - vLLM version: v0.10.0 - vLLM main: vllm-project/vllm@18cc33d Signed-off-by: huangxialu <[email protected]>
1 parent e7d32ed commit 1a25b0a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/ut/models/test_qwen3_moe.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# This file is a part of the vllm-ascend project.
14+
#
15+
16+
import pytest
17+
from vllm.model_executor.models.qwen3_moe import Qwen3MoeForCausalLM
18+
19+
from vllm_ascend.models.qwen3_moe import CustomQwen3MoeForCausalLM
20+
21+
22+
class TestCustomQwen3MoeForCausalLM:
23+
24+
def test_class_inheritance(self):
25+
assert issubclass(CustomQwen3MoeForCausalLM, Qwen3MoeForCausalLM)
26+
27+
@pytest.mark.parametrize("key, expected", [
28+
("qkv_proj", ["q_proj", "k_proj", "v_proj"]),
29+
("gate_up_proj", ["gate_proj", "up_proj"]),
30+
("experts",
31+
["experts.0.gate_proj", "experts.0.up_proj", "experts.0.down_proj"]),
32+
])
33+
def test_packed_modules_mapping(self, key, expected):
34+
assert CustomQwen3MoeForCausalLM.packed_modules_mapping[
35+
key] == expected
36+
37+
def test_packed_modules_mapping_structure(self):
38+
expected_mapping = {
39+
"qkv_proj": ["q_proj", "k_proj", "v_proj"],
40+
"gate_up_proj": ["gate_proj", "up_proj"],
41+
"experts": [
42+
"experts.0.gate_proj", "experts.0.up_proj",
43+
"experts.0.down_proj"
44+
]
45+
}
46+
assert CustomQwen3MoeForCausalLM.packed_modules_mapping == expected_mapping

0 commit comments

Comments
 (0)