@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 01bea115c4
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 13, 05:45 UTC

[Misc] Remove `warn_for_unimplemented_methods` (#28613)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>

Cyrus Leung committed Nov 14, 2025 at 11:10 UTC 01bea115c426a86c5e565a1fc0b9563f58e0bd1a
2 files changed -47
vllm/utils/__init__.py
-45
@@ -1,10 +1,8 @@
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 -import inspect
4 import uuid
5 import warnings
7 -from functools import wraps
6 from typing import Any, TypeVar
7
8 import torch
@@ -69,49 +67,6 @@ def random_uuid() -> str:
67 return str(uuid.uuid4().hex)
68
69
72 -def warn_for_unimplemented_methods(cls: type[T]) -> type[T]:
73 - """
74 - A replacement for `abc.ABC`.
75 - When we use `abc.ABC`, subclasses will fail to instantiate
76 - if they do not implement all abstract methods.
77 - Here, we only require `raise NotImplementedError` in the
78 - base class, and log a warning if the method is not implemented
79 - in the subclass.
80 - """
81 -
82 - original_init = cls.__init__
83 -
84 - def find_unimplemented_methods(self: object):
85 - unimplemented_methods = []
86 - for attr_name in dir(self):
87 - # bypass inner method
88 - if attr_name.startswith("_"):
89 - continue
90 -
91 - try:
92 - attr = getattr(self, attr_name)
93 - # get the func of callable method
94 - if callable(attr):
95 - attr_func = attr.__func__
96 - except AttributeError:
97 - continue
98 - src = inspect.getsource(attr_func)
99 - if "NotImplementedError" in src:
100 - unimplemented_methods.append(attr_name)
101 - if unimplemented_methods:
102 - method_names = ",".join(unimplemented_methods)
103 - msg = f"Methods {method_names} not implemented in {self}"
104 - logger.debug(msg)
105 -
106 - @wraps(original_init)
107 - def wrapped_init(self, *args, **kwargs) -> None:
108 - original_init(self, *args, **kwargs)
109 - find_unimplemented_methods(self)
110 -
111 - type.__setattr__(cls, "__init__", wrapped_init)
112 - return cls
113 -
114 -
70 def length_from_prompt_token_ids_or_embeds(
71 prompt_token_ids: list[int] | None,
72 prompt_embeds: torch.Tensor | None,
vllm/v1/worker/worker_base.py
-2
@@ -13,7 +13,6 @@ from vllm.logger import init_logger
13 from vllm.lora.request import LoRARequest
14 from vllm.multimodal import MULTIMODAL_REGISTRY
15 from vllm.multimodal.cache import worker_receiver_cache_from_config
16 -from vllm.utils import warn_for_unimplemented_methods
16 from vllm.utils.import_utils import resolve_obj_by_qualname
17 from vllm.utils.system_utils import update_environment_variables
18 from vllm.v1.kv_cache_interface import KVCacheSpec
@@ -33,7 +32,6 @@ logger = init_logger(__name__)
32 _R = TypeVar("_R")
33
34
36 -@warn_for_unimplemented_methods
35 class WorkerBase:
36 """Worker interface that allows vLLM to cleanly separate implementations for
37 different hardware. Also abstracts control plane communication, e.g., to