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 8, 07:30 UTC
fix: use `__annotations__` instead of `get_type_hints()` for dynamic `kwargs` detection (#34527)
Signed-off-by: Christian S. Perone <christian.perone@gmail.com> Signed-off-by: Christian S. Perone <perone@users.noreply.github.com> Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com>
Christian S. Perone committed
Feb 14, 2026 at 04:03 UTC
0ef5b9147bb1f37c9a90ab2a3ee2a85cf9e84e30
1 file changed
+11
-1
vllm/transformers_utils/processor.py
+11
-1
@@ -18,10 +18,13 @@ from transformers.processing_utils import ProcessorMixin
18
from transformers.video_processing_utils import BaseVideoProcessor
19
from typing_extensions import TypeVar
20
21
+from vllm.logger import init_logger
22
from vllm.transformers_utils.gguf_utils import is_gguf
23
from vllm.transformers_utils.utils import convert_model_repo_to_path
24
from vllm.utils.func_utils import get_allowed_kwarg_only_overrides
25
26
+logger = init_logger(__name__)
27
+
28
if TYPE_CHECKING:
29
from vllm.config import ModelConfig
30
@@ -68,7 +71,13 @@ def _collect_dynamic_keys_from_processing_kwargs(kwargs_cls: type) -> set[str]:
71
kwargs_type_annotations = get_type_hints(kwargs_cls)
72
for kw_type in ("text_kwargs", "images_kwargs", "videos_kwargs", "audio_kwargs"):
73
if kw_type in kwargs_type_annotations:
71
- kw_annotations = get_type_hints(kwargs_type_annotations[kw_type])
74
+ # Use __annotations__ instead of get_type_hints() to avoid
75
+ # NameError from unresolved forward references (e.g.
76
+ # PILImageResampling). We only need key names, not types.
77
+ kw_cls = kwargs_type_annotations[kw_type]
78
+ kw_annotations: dict[str, Any] = {}
79
+ for base in reversed(kw_cls.__mro__):
80
+ kw_annotations.update(getattr(base, "__annotations__", {}))
81
for kw_name in kw_annotations:
82
dynamic_kwargs.add(kw_name)
83
dynamic_kwargs |= {"text_kwargs", "images_kwargs", "videos_kwargs", "audio_kwargs"}
@@ -195,6 +204,7 @@ def get_processor_kwargs_from_processor(processor: _P) -> set[str]:
204
)
205
return processor_kwargs
206
except Exception:
207
+ logger.exception("Failed to collect processor kwargs")
208
return set()
209
210