Skip to content

Commit ce4970e

Browse files
authored
[Test] Add unit test for schedule_config.py (#1590)
What this PR does / why we need it? According to issue #1298 , this pull request adds unit test code for schedule_config.py. Does this PR introduce any user-facing change? No How was this patch tested? CI passed with new added/existing test. - vLLM version: v0.9.2 - vLLM main: vllm-project/vllm@8d0a01a
1 parent 5f0b42e commit ce4970e

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

tests/ut/core/test_schedule_config.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
from vllm.config import SchedulerConfig
17+
18+
from tests.ut.base import TestBase
19+
from vllm_ascend.core.schedule_config import AscendSchedulerConfig
20+
21+
22+
class TestAscendSchedulerConfig(TestBase):
23+
24+
def setUp(self):
25+
self.basic_scheduler_config = SchedulerConfig(
26+
max_num_batched_tokens=8192,
27+
is_multimodal_model=False,
28+
send_delta_data=False,
29+
scheduler_delay_factor=0,
30+
)
31+
32+
def test_initialize_from_config_with_default(self):
33+
# No additional config given, check the default value here.
34+
ascend_config = AscendSchedulerConfig.initialize_from_config(
35+
self.basic_scheduler_config, {})
36+
self.assertEqual(ascend_config.enable_chunked_prefill, False)
37+
self.assertEqual(ascend_config.policy, "fcfs")
38+
self.assertEqual(ascend_config.num_scheduler_steps, 1)
39+
self.assertEqual(ascend_config.scheduler_cls,
40+
"vllm_ascend.core.scheduler.AscendScheduler")
41+
self.assertEqual(ascend_config.max_num_encoder_input_tokens, 8192)
42+
self.assertEqual(ascend_config.encoder_cache_size, 8192)
43+
44+
def test_initialize_from_config_with_override(self):
45+
# test override
46+
ascend_config = AscendSchedulerConfig.initialize_from_config(
47+
self.basic_scheduler_config,
48+
AscendSchedulerConfig(
49+
enable_chunked_prefill=False,
50+
policy="fcfs",
51+
num_scheduler_steps=1,
52+
scheduler_cls="vllm_ascend.core.scheduler.AscendScheduler",
53+
max_num_batched_tokens=2048,
54+
),
55+
)
56+
self.assertEqual(ascend_config.enable_chunked_prefill, False)
57+
self.assertEqual(ascend_config.policy, "fcfs")
58+
self.assertEqual(ascend_config.num_scheduler_steps, 1)
59+
self.assertEqual(ascend_config.scheduler_cls,
60+
"vllm_ascend.core.scheduler.AscendScheduler")
61+
self.assertEqual(ascend_config.max_num_batched_tokens, 2048)
62+
self.assertEqual(ascend_config.encoder_cache_size, 2048)
63+
64+
def test_not_implemented_policy(self):
65+
with self.assertRaises(NotImplementedError) as context:
66+
AscendSchedulerConfig.initialize_from_config(
67+
self.basic_scheduler_config,
68+
AscendSchedulerConfig(policy="custom_policy", ),
69+
)
70+
self.assertIn(
71+
"currently AscendScheduler only supports fcfs policy",
72+
str(context.exception),
73+
)
74+
75+
def test_not_implemented_multimodal(self):
76+
with self.assertRaises(NotImplementedError) as context:
77+
AscendSchedulerConfig.initialize_from_config(
78+
SchedulerConfig(is_multimodal_model=True), {})
79+
self.assertIn("currently AscendScheduler only supports LLM models",
80+
str(context.exception))
81+
82+
def test_not_implemented_multi_step(self):
83+
with self.assertRaises(NotImplementedError) as context:
84+
AscendSchedulerConfig.initialize_from_config(
85+
self.basic_scheduler_config,
86+
AscendSchedulerConfig(num_scheduler_steps=2),
87+
)
88+
self.assertIn(
89+
"currently AscendScheduler doesn't support multi-step",
90+
str(context.exception),
91+
)
92+
93+
def test_not_implemented_send_delta_data(self):
94+
with self.assertRaises(NotImplementedError) as context:
95+
AscendSchedulerConfig.initialize_from_config(
96+
self.basic_scheduler_config,
97+
AscendSchedulerConfig(send_delta_data=True))
98+
self.assertIn(
99+
"currently AscendScheduler doesn't support send_delta_data",
100+
str(context.exception),
101+
)
102+
103+
def test_not_implemented_delay_factor(self):
104+
with self.assertRaises(NotImplementedError) as context:
105+
AscendSchedulerConfig.initialize_from_config(
106+
self.basic_scheduler_config,
107+
AscendSchedulerConfig(delay_factor=1))
108+
self.assertIn(
109+
"currently AscendScheduler doesn't support scheduler_delay_factor",
110+
str(context.exception),
111+
)
112+
113+
def test_no_override(self):
114+
ascend_config = AscendSchedulerConfig.initialize_from_config(
115+
self.basic_scheduler_config, {})
116+
self.assertEqual(ascend_config.max_num_encoder_input_tokens, 8192)
117+
self.assertEqual(ascend_config.encoder_cache_size, 8192)

0 commit comments

Comments
 (0)