From 01bea115c426a86c5e565a1fc0b9563f58e0bd1a Mon Sep 17 00:00:00 2001 From: Cyrus Leung Date: Fri, 14 Nov 2025 11:10:10 +0800 Subject: [PATCH] [Misc] Remove `warn_for_unimplemented_methods` (#28613) Signed-off-by: DarkLight1337 --- vllm/utils/__init__.py | 45 ----------------------------------- vllm/v1/worker/worker_base.py | 2 -- 2 files changed, 47 deletions(-) diff --git a/vllm/utils/__init__.py b/vllm/utils/__init__.py index 9b0045279a67e..040c0416c5ea9 100644 --- a/vllm/utils/__init__.py +++ b/vllm/utils/__init__.py @@ -1,10 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project -import inspect import uuid import warnings -from functools import wraps from typing import Any, TypeVar import torch @@ -69,49 +67,6 @@ def random_uuid() -> str: return str(uuid.uuid4().hex) -def warn_for_unimplemented_methods(cls: type[T]) -> type[T]: - """ - A replacement for `abc.ABC`. - When we use `abc.ABC`, subclasses will fail to instantiate - if they do not implement all abstract methods. - Here, we only require `raise NotImplementedError` in the - base class, and log a warning if the method is not implemented - in the subclass. - """ - - original_init = cls.__init__ - - def find_unimplemented_methods(self: object): - unimplemented_methods = [] - for attr_name in dir(self): - # bypass inner method - if attr_name.startswith("_"): - continue - - try: - attr = getattr(self, attr_name) - # get the func of callable method - if callable(attr): - attr_func = attr.__func__ - except AttributeError: - continue - src = inspect.getsource(attr_func) - if "NotImplementedError" in src: - unimplemented_methods.append(attr_name) - if unimplemented_methods: - method_names = ",".join(unimplemented_methods) - msg = f"Methods {method_names} not implemented in {self}" - logger.debug(msg) - - @wraps(original_init) - def wrapped_init(self, *args, **kwargs) -> None: - original_init(self, *args, **kwargs) - find_unimplemented_methods(self) - - type.__setattr__(cls, "__init__", wrapped_init) - return cls - - def length_from_prompt_token_ids_or_embeds( prompt_token_ids: list[int] | None, prompt_embeds: torch.Tensor | None, diff --git a/vllm/v1/worker/worker_base.py b/vllm/v1/worker/worker_base.py index 30ea0ab77bd9e..3991c16eefba9 100644 --- a/vllm/v1/worker/worker_base.py +++ b/vllm/v1/worker/worker_base.py @@ -13,7 +13,6 @@ from vllm.logger import init_logger from vllm.lora.request import LoRARequest from vllm.multimodal import MULTIMODAL_REGISTRY from vllm.multimodal.cache import worker_receiver_cache_from_config -from vllm.utils import warn_for_unimplemented_methods from vllm.utils.import_utils import resolve_obj_by_qualname from vllm.utils.system_utils import update_environment_variables from vllm.v1.kv_cache_interface import KVCacheSpec @@ -33,7 +32,6 @@ logger = init_logger(__name__) _R = TypeVar("_R") -@warn_for_unimplemented_methods class WorkerBase: """Worker interface that allows vLLM to cleanly separate implementations for different hardware. Also abstracts control plane communication, e.g., to