@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / f6027b2855
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

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

Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>

wangxiyuan committed Oct 22, 2025 at 17:04 UTC f6027b28553da470d9821a25a0addf9472c6834a
7 files changed +21 -106
tests/models/quantization/test_fp8.py
+5 -2
@@ -9,6 +9,7 @@ Note: these tests will only pass on L4 GPU.
9 import pytest
10
11 from tests.quantization.utils import is_quant_method_supported
12 +from vllm.attention.utils.fa_utils import flash_attn_supports_fp8
13 from vllm.platforms import current_platform
14 from vllm.utils import STR_BACKEND_ENV_VAR
15
@@ -69,8 +70,10 @@ def test_models(
70 if kv_cache_dtype == "fp8_e5m2" and current_platform.is_rocm():
71 pytest.skip(f"{kv_cache_dtype} is currently not supported on ROCm/HIP.")
72
72 - if not current_platform.is_kv_cache_dtype_supported(kv_cache_dtype, None):
73 - pytest.skip(f"{kv_cache_dtype} is not supported on this platform.")
73 + if not flash_attn_supports_fp8():
74 + pytest.skip(
75 + f"{kv_cache_dtype} is not supported on this GPU type with {backend} attention."
76 + )
77
78 with monkeypatch.context() as m:
79 m.setenv("TOKENIZERS_PARALLELISM", "true")
tests/quantization/test_compressed_tensors.py
-4
@@ -356,10 +356,6 @@ def test_compressed_tensors_fp8(vllm_runner):
356 assert output
357
358
359 -@pytest.mark.skipif(
360 - not current_platform.is_kv_cache_dtype_supported("fp8", None),
361 - reason="FP8 KV cache is not supported on this device.",
362 -)
359 @pytest.mark.skipif(
360 not current_platform.is_cuda(), reason="This test is skipped on non-CUDA platform."
361 )
vllm/platforms/cuda.py
+1 -44
@@ -23,7 +23,7 @@ from .interface import DeviceCapability, Platform, PlatformEnum
23
24 if TYPE_CHECKING:
25 from vllm.attention.backends.registry import _Backend
26 - from vllm.config import ModelConfig, VllmConfig
26 + from vllm.config import VllmConfig
27 else:
28 _Backend = None
29
@@ -457,49 +457,6 @@ class CudaPlatformBase(Platform):
457 def device_count(cls) -> int:
458 return cuda_device_count_stateless()
459
460 - @classmethod
461 - def is_kv_cache_dtype_supported(
462 - cls, kv_cache_dtype: str, model_config: "ModelConfig"
463 - ) -> bool:
464 - fp8_attention = kv_cache_dtype.startswith("fp8")
465 - attention_backend = envs.VLLM_ATTENTION_BACKEND
466 -
467 - supported = False
468 - if model_config is not None and model_config.use_mla:
469 - # Default to CutlassMLA for blackwell,
470 - # FlashMLA otherwise
471 - if attention_backend is None:
472 - if cls.is_device_capability(100):
473 - attention_backend = "CUTLASS_MLA"
474 - else:
475 - attention_backend = "FLASHMLA"
476 -
477 - # Only FlashMLA and CUTLASS_MLA support fp8
478 - if attention_backend in ["FLASHMLA", "CUTLASS_MLA", "FLASHINFER_MLA"]:
479 - supported = True
480 - else:
481 - supported = not fp8_attention
482 - else:
483 - # Default to FlashAttention
484 - if attention_backend is None:
485 - attention_backend = "FLASH_ATTN"
486 -
487 - # All Blackwell backends support fp8
488 - if cls.is_device_capability(100):
489 - supported = True
490 - elif attention_backend == "FLASH_ATTN":
491 - if fp8_attention:
492 - from vllm.attention.utils.fa_utils import flash_attn_supports_fp8
493 -
494 - supported = flash_attn_supports_fp8()
495 - else:
496 - supported = True
497 - elif attention_backend == "FLASHINFER":
498 - supported = True
499 - elif attention_backend == "TRITON_ATTN":
500 - supported = cls.supports_fp8()
501 - return supported
502 -
460 @classmethod
461 def check_if_supports_dtype(cls, dtype: torch.dtype):
462 if dtype == torch.bfloat16: # noqa: SIM102
vllm/platforms/interface.py
+14 -27
@@ -7,28 +7,23 @@ import platform
7 import random
8 import sys
9 from datetime import timedelta
10 -from platform import uname
10 from typing import TYPE_CHECKING, Any, NamedTuple
11
12 import numpy as np
13 import torch
15 -from torch.distributed import PrefixStore, ProcessGroup
14
17 -from vllm.inputs import ProcessorInputs, PromptType
15 from vllm.logger import init_logger
16
17 if TYPE_CHECKING:
18 + from torch.distributed import PrefixStore, ProcessGroup
19 +
20 from vllm.attention.backends.registry import _Backend
22 - from vllm.config import ModelConfig, VllmConfig
21 + from vllm.config import VllmConfig
22 + from vllm.inputs import ProcessorInputs, PromptType
23 from vllm.pooling_params import PoolingParams
24 from vllm.sampling_params import SamplingParams
25 from vllm.utils import FlexibleArgumentParser
26 else:
27 - _Backend = object
28 - ModelConfig = object
29 - VllmConfig = object
30 - PoolingParams = object
31 - SamplingParams = object
27 FlexibleArgumentParser = object
28
29 logger = init_logger(__name__)
@@ -36,7 +31,7 @@ logger = init_logger(__name__)
31
32 def in_wsl() -> bool:
33 # Reference: https://github.com/microsoft/WSL/issues/4071
39 - return "microsoft" in " ".join(uname()).lower()
34 + return "microsoft" in " ".join(platform.uname()).lower()
35
36
37 class PlatformEnum(enum.Enum):
@@ -178,7 +173,8 @@ class Platform:
173 import vllm._moe_C # noqa: F401
174
175 @classmethod
181 - def get_vit_attn_backend(cls, head_size: int, dtype: torch.dtype) -> _Backend:
176 + def get_vit_attn_backend(cls, head_size: int, dtype: torch.dtype) -> "_Backend":
177 + # Import _Backend here to avoid circular import.
178 from vllm.attention.backends.registry import _Backend
179
180 return _Backend.TORCH_SDPA
@@ -186,7 +182,7 @@ class Platform:
182 @classmethod
183 def get_attn_backend_cls(
184 cls,
189 - selected_backend: _Backend,
185 + selected_backend: "_Backend",
186 head_size: int,
187 dtype: torch.dtype,
188 kv_cache_dtype: str | None,
@@ -317,7 +313,7 @@ class Platform:
313 pass
314
315 @classmethod
320 - def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
316 + def check_and_update_config(cls, vllm_config: "VllmConfig") -> None:
317 """
318 Check and update the configuration for the current platform.
319
@@ -498,9 +494,9 @@ class Platform:
494 @classmethod
495 def validate_request(
496 cls,
501 - prompt: PromptType,
502 - params: SamplingParams | PoolingParams,
503 - processed_inputs: ProcessorInputs,
497 + prompt: "PromptType",
498 + params: "SamplingParams | PoolingParams",
499 + processed_inputs: "ProcessorInputs",
500 ) -> None:
501 """Raises if this request is unsupported on this platform"""
502
@@ -543,25 +539,16 @@ class Platform:
539 def stateless_init_device_torch_dist_pg(
540 cls,
541 backend: str,
546 - prefix_store: PrefixStore,
542 + prefix_store: "PrefixStore",
543 group_rank: int,
544 group_size: int,
545 timeout: timedelta,
550 - ) -> ProcessGroup:
546 + ) -> "ProcessGroup":
547 """
548 Init platform-specific torch distributed process group.
549 """
550 raise NotImplementedError
551
556 - @classmethod
557 - def is_kv_cache_dtype_supported(
558 - cls, kv_cache_dtype: str, model_config: ModelConfig
559 - ) -> bool:
560 - """
561 - Returns if the kv_cache_dtype is supported by the current platform.
562 - """
563 - return False
564 -
552 @classmethod
553 def check_if_supports_dtype(cls, dtype: torch.dtype):
554 """
vllm/platforms/rocm.py
+1 -7
@@ -15,7 +15,7 @@ from .interface import DeviceCapability, Platform, PlatformEnum
15
16 if TYPE_CHECKING:
17 from vllm.attention.backends.registry import _Backend
18 - from vllm.config import ModelConfig, VllmConfig
18 + from vllm.config import VllmConfig
19 else:
20 _Backend = None
21
@@ -474,12 +474,6 @@ class RocmPlatform(Platform):
474 def device_count(cls) -> int:
475 return cuda_device_count_stateless()
476
477 - @classmethod
478 - def is_kv_cache_dtype_supported(
479 - cls, kv_cache_dtype: str, model_config: "ModelConfig"
480 - ) -> bool:
481 - return True
482 -
477 @classmethod
478 def check_if_supports_dtype(cls, dtype: torch.dtype):
479 if dtype == torch.bfloat16: # noqa: SIM102
vllm/platforms/tpu.py
-6
@@ -222,12 +222,6 @@ class TpuPlatform(Platform):
222 ):
223 raise ValueError("Torch XLA does not support per-request seed.")
224
225 - @classmethod
226 - def is_kv_cache_dtype_supported(
227 - cls, kv_cache_dtype: str, model_config: "ModelConfig"
228 - ) -> bool:
229 - return True
230 -
225 @classmethod
226 @torch.compile(backend="openxla")
227 def insert_blocks_to_device(
vllm/platforms/xpu.py
-16
@@ -86,22 +86,6 @@ class XPUPlatform(Platform):
86 logger.info("Using Flash Attention backend on V1 engine.")
87 return "vllm.v1.attention.backends.flash_attn.FlashAttentionBackend"
88
89 - @classmethod
90 - def is_kv_cache_dtype_supported(
91 - cls, kv_cache_dtype: str, model_config: "ModelConfig"
92 - ) -> bool:
93 - """
94 - Check if the kv_cache_dtype is supported.
95 - XPU only support fp8 kv cache with triton backend.
96 - """
97 - if (
98 - envs.is_set("VLLM_ATTENTION_BACKEND")
99 - and envs.VLLM_ATTENTION_BACKEND == "TRITON_ATTN"
100 - ):
101 - return kv_cache_dtype in ["fp8_e4m3", "fp8_e5m2", "fp8"]
102 -
103 - return False
104 -
89 @classmethod
90 def set_device(cls, device: torch.device) -> None:
91 """