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 7, 21:30 UTC
Fix custom processors that use deleted import for Transformers v5 (#35101)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Harry Mellor committed
Feb 23, 2026 at 16:38 UTC
864167d37690f0ac1b94ae9938fc0fdffbc51225
1 file changed
+18
vllm/transformers_utils/processor.py
+18
@@ -11,6 +11,7 @@ from transformers import (
11
AutoImageProcessor,
12
AutoProcessor,
13
AutoVideoProcessor,
14
+ processing_utils,
15
)
16
from transformers.feature_extraction_utils import FeatureExtractionMixin
17
from transformers.image_processing_utils import BaseImageProcessor
@@ -28,6 +29,23 @@ logger = init_logger(__name__)
29
if TYPE_CHECKING:
30
from vllm.config import ModelConfig
31
32
+
33
+def _transformers_v4_compatibility_import():
34
+ """Some remote code processors still import `ChatTemplateLoadKwargs` which was a
35
+ subset of `ProcessorChatTemplateKwargs` as defined in Transformers v4.
36
+ In Transformers v5 these were merged into `ProcessorChatTemplateKwargs` and
37
+ `ChatTemplateLoadKwargs` was removed. For backward compatibility, we add an alias
38
+ for `ChatTemplateLoadKwargs` if it doesn't exist.
39
+
40
+ This can be removed if `HCXVisionForCausalLM` is upstreamed to Transformers."""
41
+ old_import = getattr(processing_utils, "ChatTemplateLoadKwargs", None)
42
+ new_import = getattr(processing_utils, "ProcessorChatTemplateKwargs", None)
43
+ if old_import is None and new_import is not None:
44
+ processing_utils.ChatTemplateLoadKwargs = new_import
45
+
46
+
47
+_transformers_v4_compatibility_import()
48
+
49
_P = TypeVar("_P", bound=ProcessorMixin, default=ProcessorMixin)
50
_V = TypeVar("_V", bound=BaseVideoProcessor, default=BaseVideoProcessor)
51