[1/N][Platform] Cleanup useless function (#26982)

Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
This commit is contained in:
wangxiyuan
2025-10-22 09:04:57 +00:00
committed by GitHub
parent ab3e80042e
commit f6027b2855
7 changed files with 21 additions and 106 deletions
+14 -27
View File
@@ -7,28 +7,23 @@ import platform
import random
import sys
from datetime import timedelta
from platform import uname
from typing import TYPE_CHECKING, Any, NamedTuple
import numpy as np
import torch
from torch.distributed import PrefixStore, ProcessGroup
from vllm.inputs import ProcessorInputs, PromptType
from vllm.logger import init_logger
if TYPE_CHECKING:
from torch.distributed import PrefixStore, ProcessGroup
from vllm.attention.backends.registry import _Backend
from vllm.config import ModelConfig, VllmConfig
from vllm.config import VllmConfig
from vllm.inputs import ProcessorInputs, PromptType
from vllm.pooling_params import PoolingParams
from vllm.sampling_params import SamplingParams
from vllm.utils import FlexibleArgumentParser
else:
_Backend = object
ModelConfig = object
VllmConfig = object
PoolingParams = object
SamplingParams = object
FlexibleArgumentParser = object
logger = init_logger(__name__)
@@ -36,7 +31,7 @@ logger = init_logger(__name__)
def in_wsl() -> bool:
# Reference: https://github.com/microsoft/WSL/issues/4071
return "microsoft" in " ".join(uname()).lower()
return "microsoft" in " ".join(platform.uname()).lower()
class PlatformEnum(enum.Enum):
@@ -178,7 +173,8 @@ class Platform:
import vllm._moe_C # noqa: F401
@classmethod
def get_vit_attn_backend(cls, head_size: int, dtype: torch.dtype) -> _Backend:
def get_vit_attn_backend(cls, head_size: int, dtype: torch.dtype) -> "_Backend":
# Import _Backend here to avoid circular import.
from vllm.attention.backends.registry import _Backend
return _Backend.TORCH_SDPA
@@ -186,7 +182,7 @@ class Platform:
@classmethod
def get_attn_backend_cls(
cls,
selected_backend: _Backend,
selected_backend: "_Backend",
head_size: int,
dtype: torch.dtype,
kv_cache_dtype: str | None,
@@ -317,7 +313,7 @@ class Platform:
pass
@classmethod
def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
def check_and_update_config(cls, vllm_config: "VllmConfig") -> None:
"""
Check and update the configuration for the current platform.
@@ -498,9 +494,9 @@ class Platform:
@classmethod
def validate_request(
cls,
prompt: PromptType,
params: SamplingParams | PoolingParams,
processed_inputs: ProcessorInputs,
prompt: "PromptType",
params: "SamplingParams | PoolingParams",
processed_inputs: "ProcessorInputs",
) -> None:
"""Raises if this request is unsupported on this platform"""
@@ -543,25 +539,16 @@ class Platform:
def stateless_init_device_torch_dist_pg(
cls,
backend: str,
prefix_store: PrefixStore,
prefix_store: "PrefixStore",
group_rank: int,
group_size: int,
timeout: timedelta,
) -> ProcessGroup:
) -> "ProcessGroup":
"""
Init platform-specific torch distributed process group.
"""
raise NotImplementedError
@classmethod
def is_kv_cache_dtype_supported(
cls, kv_cache_dtype: str, model_config: ModelConfig
) -> bool:
"""
Returns if the kv_cache_dtype is supported by the current platform.
"""
return False
@classmethod
def check_if_supports_dtype(cls, dtype: torch.dtype):
"""