"...git@developer.sourcefind.cn:2222/OpenDAS/vllm_cscc.git" did not exist on "d4629dc43f92c189e90a3e2f2f8a52648aed4d9d"
Unverified Commit 01bea115 authored by Cyrus Leung's avatar Cyrus Leung Committed by GitHub
Browse files

[Misc] Remove `warn_for_unimplemented_methods` (#28613)


Signed-off-by: default avatarDarkLight1337 <tlleungac@connect.ust.hk>
parent b39a5026
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import inspect
import uuid import uuid
import warnings import warnings
from functools import wraps
from typing import Any, TypeVar from typing import Any, TypeVar
import torch import torch
...@@ -69,49 +67,6 @@ def random_uuid() -> str: ...@@ -69,49 +67,6 @@ def random_uuid() -> str:
return str(uuid.uuid4().hex) 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( def length_from_prompt_token_ids_or_embeds(
prompt_token_ids: list[int] | None, prompt_token_ids: list[int] | None,
prompt_embeds: torch.Tensor | None, prompt_embeds: torch.Tensor | None,
......
...@@ -13,7 +13,6 @@ from vllm.logger import init_logger ...@@ -13,7 +13,6 @@ from vllm.logger import init_logger
from vllm.lora.request import LoRARequest from vllm.lora.request import LoRARequest
from vllm.multimodal import MULTIMODAL_REGISTRY from vllm.multimodal import MULTIMODAL_REGISTRY
from vllm.multimodal.cache import worker_receiver_cache_from_config 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.import_utils import resolve_obj_by_qualname
from vllm.utils.system_utils import update_environment_variables from vllm.utils.system_utils import update_environment_variables
from vllm.v1.kv_cache_interface import KVCacheSpec from vllm.v1.kv_cache_interface import KVCacheSpec
...@@ -33,7 +32,6 @@ logger = init_logger(__name__) ...@@ -33,7 +32,6 @@ logger = init_logger(__name__)
_R = TypeVar("_R") _R = TypeVar("_R")
@warn_for_unimplemented_methods
class WorkerBase: class WorkerBase:
"""Worker interface that allows vLLM to cleanly separate implementations for """Worker interface that allows vLLM to cleanly separate implementations for
different hardware. Also abstracts control plane communication, e.g., to different hardware. Also abstracts control plane communication, e.g., to
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment