[bugfix][refactor] fix recompute_scheduler break with vllm 0.12.0 & support async scheduling & refactor recompute_scheduler.py (#4895)
### What this PR does / why we need it?
Currently, the initialization and fundamental functions of
RecomputeScheduler are broken with `vLLM v0.12.0`. This PR fixes the
conflicts of `RecomputeScheduler` and refactor its implementations by
inheriting original `Scheduler` of vLLM. Meanwhile, this PR also
supports async cheduling with recompute scheduler by implementing
`AsyncRecomputeScheduler` which is simply inherited `AsncyScheduler` of
vLLM and `RecomputeScheduler` of vLLM-Ascend with python MRO.
### Does this PR introduce _any_ user-facing change?
No. The switch naming is the same as v0.11.0 :
`recompute_scheduler_enable`
### How was this patch tested?
E2E serving with 2P1D dsv3.1 passed. The performance was the same as
original vllm scheduler with `async_scheduling` and preempted requests
in D Nodes are successfully transfered to Proxy and further to P Node.
This significantly improves the performance and robustness of PD
disaggregation deployments.
- vLLM version: v0.12.0
- vLLM main:
ad32e3e19c
---------
Signed-off-by: linfeng-yuan <1102311262@qq.com>
This commit is contained in:
@@ -234,7 +234,7 @@ class TestNPUPlatform(TestBase):
|
|||||||
return_value=AscendDeviceType._910_93)
|
return_value=AscendDeviceType._910_93)
|
||||||
@patch("os.environ", {})
|
@patch("os.environ", {})
|
||||||
@patch(
|
@patch(
|
||||||
"vllm_ascend.core.recompute_schedule_config.RecomputeSchedulerConfig.initialize_from_config"
|
"vllm_ascend.core.recompute_scheduler.RecomputeSchedulerConfig.initialize_from_config"
|
||||||
)
|
)
|
||||||
def test_check_and_update_config_basic_config_update(
|
def test_check_and_update_config_basic_config_update(
|
||||||
self, mock_init_recompute, mock_soc_version, mock_update_acl,
|
self, mock_init_recompute, mock_soc_version, mock_update_acl,
|
||||||
@@ -266,7 +266,7 @@ class TestNPUPlatform(TestBase):
|
|||||||
return_value=AscendDeviceType._910_93)
|
return_value=AscendDeviceType._910_93)
|
||||||
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
||||||
@patch(
|
@patch(
|
||||||
"vllm_ascend.core.recompute_schedule_config.RecomputeSchedulerConfig.initialize_from_config"
|
"vllm_ascend.core.recompute_scheduler.RecomputeSchedulerConfig.initialize_from_config"
|
||||||
)
|
)
|
||||||
def test_check_and_update_config_no_model_config_warning(
|
def test_check_and_update_config_no_model_config_warning(
|
||||||
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
||||||
@@ -291,7 +291,7 @@ class TestNPUPlatform(TestBase):
|
|||||||
return_value=AscendDeviceType._910_93)
|
return_value=AscendDeviceType._910_93)
|
||||||
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
||||||
@patch(
|
@patch(
|
||||||
"vllm_ascend.core.recompute_schedule_config.RecomputeSchedulerConfig.initialize_from_config"
|
"vllm_ascend.core.recompute_scheduler.RecomputeSchedulerConfig.initialize_from_config"
|
||||||
)
|
)
|
||||||
def test_check_and_update_config_enforce_eager_mode(
|
def test_check_and_update_config_enforce_eager_mode(
|
||||||
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
||||||
@@ -328,7 +328,7 @@ class TestNPUPlatform(TestBase):
|
|||||||
@patch("vllm_ascend.utils.update_default_aclgraph_sizes")
|
@patch("vllm_ascend.utils.update_default_aclgraph_sizes")
|
||||||
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
||||||
@patch(
|
@patch(
|
||||||
"vllm_ascend.core.recompute_schedule_config.RecomputeSchedulerConfig.initialize_from_config"
|
"vllm_ascend.core.recompute_scheduler.RecomputeSchedulerConfig.initialize_from_config"
|
||||||
)
|
)
|
||||||
def test_check_and_update_config_unsupported_compilation_level(
|
def test_check_and_update_config_unsupported_compilation_level(
|
||||||
self, mock_init_recompute, mock_init_ascend, mock_update_default,
|
self, mock_init_recompute, mock_init_ascend, mock_update_default,
|
||||||
@@ -397,7 +397,7 @@ class TestNPUPlatform(TestBase):
|
|||||||
return_value=AscendDeviceType._910_93)
|
return_value=AscendDeviceType._910_93)
|
||||||
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
||||||
@patch(
|
@patch(
|
||||||
"vllm_ascend.core.recompute_schedule_config.RecomputeSchedulerConfig.initialize_from_config"
|
"vllm_ascend.core.recompute_scheduler.RecomputeSchedulerConfig.initialize_from_config"
|
||||||
)
|
)
|
||||||
def test_check_and_update_config_cache_config_block_size(
|
def test_check_and_update_config_cache_config_block_size(
|
||||||
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
||||||
@@ -424,7 +424,7 @@ class TestNPUPlatform(TestBase):
|
|||||||
return_value=AscendDeviceType._910_93)
|
return_value=AscendDeviceType._910_93)
|
||||||
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
@patch("vllm_ascend.ascend_config.init_ascend_config")
|
||||||
@patch(
|
@patch(
|
||||||
"vllm_ascend.core.recompute_schedule_config.RecomputeSchedulerConfig.initialize_from_config"
|
"vllm_ascend.core.recompute_scheduler.RecomputeSchedulerConfig.initialize_from_config"
|
||||||
)
|
)
|
||||||
def test_check_and_update_config_v1_worker_class_selection(
|
def test_check_and_update_config_v1_worker_class_selection(
|
||||||
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
self, mock_init_recompute, mock_init_ascend, mock_soc_version):
|
||||||
@@ -462,7 +462,7 @@ class TestNPUPlatform(TestBase):
|
|||||||
@patch('vllm_ascend.utils.get_ascend_device_type',
|
@patch('vllm_ascend.utils.get_ascend_device_type',
|
||||||
return_value=AscendDeviceType._310P)
|
return_value=AscendDeviceType._310P)
|
||||||
@patch(
|
@patch(
|
||||||
"vllm_ascend.core.recompute_schedule_config.RecomputeSchedulerConfig.initialize_from_config"
|
"vllm_ascend.core.recompute_scheduler.RecomputeSchedulerConfig.initialize_from_config"
|
||||||
)
|
)
|
||||||
def test_check_and_update_config_310p_no_custom_ops(
|
def test_check_and_update_config_310p_no_custom_ops(
|
||||||
self, mock_init_recompute, mock_soc_version, mock_init_ascend):
|
self, mock_init_recompute, mock_soc_version, mock_init_ascend):
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
# This file is a part of the vllm-ascend project.
|
|
||||||
#
|
|
||||||
|
|
||||||
from dataclasses import dataclass, fields
|
|
||||||
from typing import Type, Union
|
|
||||||
|
|
||||||
from vllm.config import SchedulerConfig
|
|
||||||
|
|
||||||
MAX_INT = 2147483647
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class RecomputeSchedulerConfig(SchedulerConfig):
|
|
||||||
scheduler_cls: Union[str, Type[object]] = (
|
|
||||||
"vllm_ascend.core.recompute_scheduler.RecomputeScheduler")
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def initialize_from_config(cls, vllm_scheduler_config: SchedulerConfig):
|
|
||||||
scheduler_config = {
|
|
||||||
field.name: getattr(vllm_scheduler_config, field.name)
|
|
||||||
for field in fields(vllm_scheduler_config) if field.init
|
|
||||||
}
|
|
||||||
scheduler_config["scheduler_cls"] = (
|
|
||||||
"vllm_ascend.core.recompute_scheduler.RecomputeScheduler")
|
|
||||||
return cls(**scheduler_config)
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -298,10 +298,9 @@ class NPUPlatform(Platform):
|
|||||||
compilation_config.custom_ops = ["all"]
|
compilation_config.custom_ops = ["all"]
|
||||||
|
|
||||||
if ascend_config.recompute_scheduler_enable:
|
if ascend_config.recompute_scheduler_enable:
|
||||||
from vllm_ascend.core.recompute_schedule_config import \
|
from vllm_ascend.core.recompute_scheduler import RecomputeSchedulerConfig
|
||||||
RecomputeSchedulerConfig
|
|
||||||
recompute_scheduler_config = RecomputeSchedulerConfig.initialize_from_config(
|
recompute_scheduler_config = RecomputeSchedulerConfig.initialize_from_config(
|
||||||
vllm_config.scheduler_config)
|
vllm_config)
|
||||||
vllm_config.scheduler_config = recompute_scheduler_config
|
vllm_config.scheduler_config = recompute_scheduler_config
|
||||||
|
|
||||||
# Extend original scheduler_config to use SchedulerDynamicBatch.
|
# Extend original scheduler_config to use SchedulerDynamicBatch.
|
||||||
|
|||||||
Reference in New Issue
Block a user