[Hardware][TPU] Add supports_async_scheduling() method to Executor interface so that it can be extended for Executor implementations. (#36924)
Signed-off-by: Guangxiang Du <gxd@google.com>
This commit is contained in:
@@ -14,12 +14,35 @@ from vllm.engine.arg_utils import AsyncEngineArgs, EngineArgs
|
|||||||
from vllm.sampling_params import SamplingParams
|
from vllm.sampling_params import SamplingParams
|
||||||
from vllm.v1.engine.async_llm import AsyncLLM
|
from vllm.v1.engine.async_llm import AsyncLLM
|
||||||
from vllm.v1.engine.llm_engine import LLMEngine
|
from vllm.v1.engine.llm_engine import LLMEngine
|
||||||
|
from vllm.v1.executor.abstract import Executor
|
||||||
from vllm.v1.executor.multiproc_executor import MultiprocExecutor
|
from vllm.v1.executor.multiproc_executor import MultiprocExecutor
|
||||||
|
from vllm.v1.executor.uniproc_executor import (
|
||||||
|
ExecutorWithExternalLauncher,
|
||||||
|
UniProcExecutor,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Mock: ...
|
class Mock: ...
|
||||||
|
|
||||||
|
|
||||||
|
def test_supports_async_scheduling_base_executor():
|
||||||
|
assert Executor.supports_async_scheduling() is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_supports_async_scheduling_uniproc_executor():
|
||||||
|
assert UniProcExecutor.supports_async_scheduling() is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_supports_async_scheduling_executor_with_external_launcher():
|
||||||
|
# ExecutorWithExternalLauncher inherits from UniProcExecutor and does not
|
||||||
|
# override supports_async_scheduling, so it should return True.
|
||||||
|
assert ExecutorWithExternalLauncher.supports_async_scheduling() is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_supports_async_scheduling_multiproc_executor():
|
||||||
|
assert MultiprocExecutor.supports_async_scheduling() is True
|
||||||
|
|
||||||
|
|
||||||
class CustomMultiprocExecutor(MultiprocExecutor):
|
class CustomMultiprocExecutor(MultiprocExecutor):
|
||||||
def collective_rpc(
|
def collective_rpc(
|
||||||
self,
|
self,
|
||||||
|
|||||||
+6
-10
@@ -682,12 +682,11 @@ class VllmConfig:
|
|||||||
self.model_config, self.load_config
|
self.model_config, self.load_config
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from vllm.v1.executor.abstract import Executor
|
||||||
|
|
||||||
executor_backend = self.parallel_config.distributed_executor_backend
|
executor_backend = self.parallel_config.distributed_executor_backend
|
||||||
executor_supports_async_sched = executor_backend in (
|
executor_class = Executor.get_class(self)
|
||||||
"mp",
|
executor_supports_async_sched = executor_class.supports_async_scheduling()
|
||||||
"uni",
|
|
||||||
"external_launcher",
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.scheduler_config.async_scheduling:
|
if self.scheduler_config.async_scheduling:
|
||||||
# Async scheduling explicitly enabled, hard fail any incompatibilities.
|
# Async scheduling explicitly enabled, hard fail any incompatibilities.
|
||||||
@@ -711,9 +710,7 @@ class VllmConfig:
|
|||||||
)
|
)
|
||||||
if not executor_supports_async_sched:
|
if not executor_supports_async_sched:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Currently, async scheduling only supports `mp`, `uni`, or "
|
f"`{executor_backend}` does not support async scheduling yet."
|
||||||
"`external_launcher` distributed executor backend, but you chose "
|
|
||||||
f"`{executor_backend}`."
|
|
||||||
)
|
)
|
||||||
elif self.scheduler_config.async_scheduling is None:
|
elif self.scheduler_config.async_scheduling is None:
|
||||||
# Enable async scheduling unless there is an incompatible option.
|
# Enable async scheduling unless there is an incompatible option.
|
||||||
@@ -742,8 +739,7 @@ class VllmConfig:
|
|||||||
elif not executor_supports_async_sched:
|
elif not executor_supports_async_sched:
|
||||||
logger.warning_once(
|
logger.warning_once(
|
||||||
"Async scheduling will be disabled because it is not supported "
|
"Async scheduling will be disabled because it is not supported "
|
||||||
"with the `%s` distributed executor backend (only `mp`, `uni`, and "
|
"with the `%s` distributed executor backend. ",
|
||||||
"`external_launcher` are supported).",
|
|
||||||
executor_backend,
|
executor_backend,
|
||||||
scope="local",
|
scope="local",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -353,6 +353,13 @@ class Executor(ABC):
|
|||||||
) -> None:
|
) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def supports_async_scheduling(cls) -> bool:
|
||||||
|
"""
|
||||||
|
Whether the executor supports async scheduling.
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
from vllm.v1.executor.uniproc_executor import ( # noqa: E402
|
from vllm.v1.executor.uniproc_executor import ( # noqa: E402
|
||||||
ExecutorWithExternalLauncher as _ExecutorWithExternalLauncher,
|
ExecutorWithExternalLauncher as _ExecutorWithExternalLauncher,
|
||||||
|
|||||||
@@ -487,6 +487,10 @@ class MultiprocExecutor(Executor):
|
|||||||
* self.parallel_config.prefill_context_parallel_size
|
* self.parallel_config.prefill_context_parallel_size
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def supports_async_scheduling(cls) -> bool:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class UnreadyWorkerProcHandle:
|
class UnreadyWorkerProcHandle:
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ class UniProcExecutor(Executor):
|
|||||||
if worker := self.driver_worker:
|
if worker := self.driver_worker:
|
||||||
worker.shutdown()
|
worker.shutdown()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def supports_async_scheduling(cls) -> bool:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class ExecutorWithExternalLauncher(UniProcExecutor):
|
class ExecutorWithExternalLauncher(UniProcExecutor):
|
||||||
"""An executor that uses external launchers to launch engines,
|
"""An executor that uses external launchers to launch engines,
|
||||||
|
|||||||
Reference in New Issue
Block a user