Skip to content

Commit fce5b5d

Browse files
committed
[bugfix][refactor] fix recompute_scheduler break with vllm 0.12.0 & support async scheduling & refactor recompute_scheduler.py
Signed-off-by: linfeng-yuan <[email protected]>
1 parent 490ddf5 commit fce5b5d

File tree

4 files changed

+416
-902
lines changed

4 files changed

+416
-902
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
# This file is a part of the vllm-ascend project.
16+
#
17+
18+
from __future__ import annotations
19+
20+
from vllm.logger import init_logger
21+
from vllm.v1.core.sched.async_scheduler import AsyncScheduler
22+
23+
from vllm_ascend.core.recompute_scheduler import RecomputeScheduler
24+
25+
26+
logger = init_logger(__name__)
27+
28+
29+
class AsyncRecomputeScheduler(AsyncScheduler, RecomputeScheduler):
30+
def __init__(self, *args, **kwargs):
31+
super().__init__(*args, **kwargs)

vllm_ascend/core/recompute_schedule_config.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@
1818
from dataclasses import dataclass, fields
1919
from typing import Type, Union
2020

21-
from vllm.config import SchedulerConfig
22-
23-
MAX_INT = 2147483647
24-
21+
from vllm.config import SchedulerConfig, VllmConfig
2522

2623
@dataclass
2724
class RecomputeSchedulerConfig(SchedulerConfig):
2825
scheduler_cls: Union[str, Type[object]] = (
2926
"vllm_ascend.core.recompute_scheduler.RecomputeScheduler")
30-
3127
@classmethod
32-
def initialize_from_config(cls, vllm_scheduler_config: SchedulerConfig):
28+
def initialize_from_config(cls, vllm_config: VllmConfig):
29+
vllm_scheduler_config = vllm_config.scheduler_config
3330
scheduler_config = {
3431
field.name: getattr(vllm_scheduler_config, field.name)
3532
for field in fields(vllm_scheduler_config) if field.init
3633
}
37-
scheduler_config["scheduler_cls"] = (
38-
"vllm_ascend.core.recompute_scheduler.RecomputeScheduler")
34+
if vllm_scheduler_config.async_scheduling:
35+
scheduler_config["scheduler_cls"] = (
36+
"vllm_ascend.core.async_recompute_scheduler.AsyncRecomputeScheduler")
37+
else:
38+
scheduler_config["scheduler_cls"] = (
39+
"vllm_ascend.core.recompute_scheduler.RecomputeScheduler")
40+
scheduler_config["max_model_len"] = vllm_config.model_config.max_model_len
41+
scheduler_config["is_encoder_decoder"] = vllm_config.model_config.is_encoder_decoder
3942
return cls(**scheduler_config)

0 commit comments

Comments
 (0)